Project

General

Profile

Actions

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 Modjy and Django page: it configures everything correctly and prevents possible problems.

Similarly, the modjy and Pylons page describes the snakefight war-building tool, which does a similar job for Pylons.

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

  1. The container cannot find the jython.jar file, which contains the class file.
  2. The container cannot load the class from the jython.jar file, either for permissions or security reasons.

I recommend reading the documentation on placing the jython.jar file

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

  1. Setting the python.home property. See the modjy deployment documentation for how to do this.
  2. 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.
  3. 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 running modjy on google appengine page, under the heading "Making the jython library accessible".

Caught AttributeError while rendering: 'NoneType' object has no attribute 'endswith'

This error appears to occur when running Django on Jython, as described in this bug report: Problem with Websphere Application Server 6.1 .

As described in that bug report, the underlying error is reported from the gettext module , 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 .

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 Modjy Configuration for how to set the value of this property.

Other problems.

If you experience other problems deploying WSGI applications with modjy, then please either file a bug on the Jython bug tracker or send an email to the Jython Users mailing list.

Updated by Alan Kennedy almost 13 years ago ยท 2 revisions