ModjyTroubleShooting » History » Version 2
Alan Kennedy, 2011-06-27 08:44 PM
Adding a section on the "'NoneType' has no attribute 'endswith'" error.
h1. Trouble shooting modjy installations
By far the best way to get modjy running is to use the demo modjy application, distributed with jython, in the *Demo* directory, sub-directory *modjy_webapp*.
Don't forget to place the *jython.jar* file in the *WEB-INF/lib* directory!
If you're deploying a Django application, I highly recommend using the war packaging tool built, described on the [[ModjyAndDjango|Modjy and Django]] page: it configures everything correctly and prevents possible problems.
Similarly, the [[ModjyAndPylons|modjy and Pylons]] page describes the "snakefight":http://pypi.python.org/pypi/snakefight war-building tool, which does a similar job for Pylons.
h2(#noclassdef). java.lang.NoClassDefFoundError: com/xhaus/modjy/ModjyJServlet.
If you see this error, this means that your servlet container cannot find the java class *com.xhaus.modjy.ModjyJServlet*, which is the only java class used in modjy.
The likely cause of this issue is one of the following
# The container cannot find the *jython.jar* file, which contains the class file.
# The container cannot load the class from the *jython.jar* file, either for permissions or security reasons.
I recommend reading the documentation on [[ModjyDeployment#Placing-the-jythonjar-file|placing the jython.jar file]]
h2(#importerror). ImportError: no module named modjy
There are two parts to modjy: a java part (actually a single java class) and a jython part. The majority of modjy is implemented in jython, with the entry point in a file called *modjy.py*. The java servlet component of modjy tries to import this module: if it fails, you will see the error above.
Obviously, you have to configure things such that modjy can find the *modjy.py* module and supporting modules. Which you can do by
# Setting the *python.home* property. See the [[ModjyDeployment#Configuring-modjy|modjy deployment documentation]] for how to do this.
# You can also copy the contents of the jython *Lib* directory into the *WEB-INF/lib-python* directory. This directory is automatically added to *sys.path* and any modules contained in it can be imported. To do this, copy every file and directory from the *Lib* directory of your jython installation into *WEB-INF/lib-python*, and that should solve your import problem.
# It is also possible to package the entire jython *Lib* directory into a single file, which you then copy into *WEB-INF/lib-python*. This process is described on the [[ModjyGoogleAppEngine|running modjy on google appengine]] page, under the heading "Making the jython library accessible".
h2(#endswithnone). Caught AttributeError while rendering: 'NoneType' object has no attribute 'endswith'
This error appears to occur when running "Django on Jython":http://code.google.com/p/django-jython/, as described in this bug report: "Problem with Websphere Application Server 6.1":http://code.google.com/p/django-jython/issues/detail?id=64 .
As described in that bug report, the underlying error is reported from the "gettext module":http://docs.python.org/library/gettext.html , which needs to find data files in the jython home directory in order to do its job.
The real cause of the problem is that gettext uses the value in *sys.prefix* to find the location of the jython home directory. If the value of *sys.prefix* is None, then its attempt to load data files will fail with the "'NoneType' object has no attribute 'endswith'" error.
To fix this problem, there must be a value of *sys.prefix*. For further information on what *sys.prefix* means and how its value is set, read "Finding the registry file":http://wiki.python.org/jython/UserGuide#finding-the-registry-file .
The quickest way to solve this problem is to set a value for the *python.home* property in the *web.xml* for your modjy application. Read [[ModjyConfiguration|Modjy Configuration]] for how to set the value of this property.
h2(#other). Other problems.
If you experience other problems deploying WSGI applications with modjy, then please either file a bug on the "Jython bug tracker":http://bugs.jython.org or send an email to the "Jython Users":https://lists.sourceforge.net/lists/listinfo/jython-users mailing list.