Project

General

Profile

Actions

ModjyGoogleAppEngine » History » Revision 2

« Previous | Revision 2/9 (diff) | Next »
Alan Kennedy, 2009-04-12 09:31 PM


Running jython WSGI applcations on Google AppEngine with modjy.

Now that Google has added Java/JVM support to their AppEngine , it is now possible to run other JVM languages on it as well, including our favourite language Jython .

Modjy is the jython WSGI -> servlets gateway, used to bridge jython WSGI applications to running inside java servlet containers. And Google AppEngine is arguably one of the largest-scale servlet containers there is. And modjy can run applications on AppEngine. In order to do so, the following steps must be followed. We contributed modjy to jython a few months back .

Get a jython.jar suitable for running on AppEngine.

Because of the security constraints associated with running inside the AppEngine, e.g. not being allowed to write files, Google have provided patches to the jython project to handle these concerns.

They also provided a pre-built jython.jar file, built with these patches applied, available from here: Google's build of jython for AppEngine . But it doesn't work! (Seems that the jar was incompletely built, and excluded the jar-complete ant task in the jython build.xml file.

But worry not! We've built a fresh build of jython, from trunk@revision 6218 , with the google patches applied, that works ( we checked!). You can download it from here: jython.jar built for AppEngine .

Making the jython library accessible.

The next limitation of Google's AppEngine is that you can only upload a limit of 1,000 files for any given web application. A lot of the code for modjy resides in the Lib/modjy directory of the jython distribution. The Lib directory is pretty big, and so exceeds the file limit.

The easiest way to get around this is to upload the Library in a zip file. Simply make a zip file of the contents of the Lib directory within the directory itself, i.e. the paths inside the zip file should not start with *Lib/. (You can download such a zip file below if you're concerned about getting it wrong).

Lastly, you have to add a .pth file which refers to your newly created lib.zip. It doesn't matter what that file is called, as long as it ends in .pth. So make a simple one line text file called all.pth, and put the text "lib.zip" on that one line.

Place both the all.pth and the lib.zip file in the WEB-INF/lib directory of your web application, and you're good to go!

Appengine application descriptor

When uploading applications to AppEngine, you also need to provide an Application Descriptor . The file must reside in the web archive directory, inside WEB-INF, i.e. at the same level as the standard servlet web.xml file.

Here is the file that we use for the modjy demo application.

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>jywsgi</application>
  <version>5</version>
</appengine-web-app>

Downloading the complete finished product.

If you don't want to go through all of the steps of building stuff yourself, and going through a trial-and-error process, you can download a complete version of the modjy demo webapp for Google AppEngine .

Don't forget that you have to place the jython.jar for Google AppEngine and place it into the WEB-INF/lib directory.

You will also have to place the AppEngine runtime api jar file in the WEB-INF/lib directory as well. It is located in the lib/user directory of the AppEngine SDK download .

Deploying to Google AppEngine.

To deploy the application, issue the following command

$APP_ENGINE_SDK_HOME/bin/appcfg upload modjy_webapp

And you should be up and running.

Updated by Alan Kennedy almost 15 years ago · 2 revisions