Deployment with Django-Jython and Tomcat?

I have a Django application that we are trying to deploy to a Tomcat server using django-jython.

To test everything, I created a WAR archive file for an empty Django application. Django's test application is called a chair.

Our Tomcat server does not seem to like WAR archive files, so I exploded (unzipped this) and copied these files to the server.

The web server administrator created the context and directory for me for this context (mediatracking).

I copied the files from the WAR archive to this directory, and I'm not quite sure how to get this test application to run now?

\mediatracking - application.py - application$py.class \WEB-INF web.xml \lib - jruby-extras-fileservlet.jar - jython.jar \lib-python - Lib.pth - README \chair \django \doj \Lib 

etc .. (I did not go down lower than in the chair / django / doj / Lib directory.)

Is there anything obvious in this directory structure?

And how exactly can I get the Tomcat server to actually “run” this application? It does not start automatically if you go to the context directory (and there is only the application.py file and application $ py.class there, so I'm not sure how it will be).

Do I need to ask my web server administrator to do something with the web.xml file? I checked this, and there seems to be nothing there to help this application run:

 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>chair</display-name> <description> chair through WSGI with modjy </description> <context-param> <param-name>files.prefix</param-name> <!-- Needed by fileservlet --> <param-value></param-value> </context-param> <servlet> <servlet-name>modjy</servlet-name> <servlet-class>com.xhaus.modjy.ModjyJServlet</servlet-class> <init-param> <param-name>reload_on_mod</param-name> <param-value>1</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>fileservlet</servlet-name> <servlet-class>org.jruby.webapp.FileServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>fileservlet</servlet-name> <url-pattern>/media/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>modjy</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app> 

Any advice at all would be greatly appreciated =).

Cheers, Victor

+6
django jython tomcat
source share
2 answers

This is a late answer, but so far I have not seen this question. Hope this still helps. Here are the steps that I always follow (successfully).

1) Create a war file:

 manage war --include-java-libs "...your external jars here..." --context-root=chair 

The context-root name is important because Django-on-Jython will manipulate your settings.py file and change your MEDIA_URL and ADMINMEDIA_URL to add this context (e.g. MEDIA_URL = '/chair/media/' ) and it should be that the same context that you deploy to Tomcat. This will be the same name of the generated war file (in this case chair.war ). External JAR files contain at least your JDBC drivers.

2) Deploy the war on Tomcat (it was never a problem in any Tomcat that I used, versions 5 and 5.5). I do this manually through the HTML manager application at the URL http: // server: 8080 / manager / html - this will require authentication, use the username / password with manager privileges in Tomcat conf/users.xml I think (I'm writing from memory ) There are many ways to automate this with Ant, Maven, or other tools, but the guide is just fine.

If you absolutely need to manually download the file, use a folder name that exactly matches the war file (and therefore the context root), in this case webapps / chair in the Tomcat installation folder.

3) Get access to the deployed application from the URL http: // server: 8080 / chair / (plus any additional URL specified in urls.py)

The Modjy servlet is the one that serves your URLs, as defined in:

  <servlet-mapping> <servlet-name>modjy</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> 

If you don’t see what you expect in http: // server: 8080 / chair / , check in the HTML manager that the application was really running and check Tomcat for errors (usually logs / catalina.out in the tomcat installation directory).

Further information in the white paper: http://packages.python.org/django-jython/war-deployment.html

+2
source share

I do not see any configuration in your web.xml that actually indicates the object called by WSGI: one is required before the application starts.

See here how to specify calls for modjy.

http://opensource.xhaus.com/projects/modjy/wiki/ModjyLocateCallables

Alternatively, compare your web.xml with web.xml in the modjy demo web application.

https://fisheye3.atlassian.com/browse/jython/trunk/jython/Demo/modjy_webapp/WEB-INF/web.xml

0
source share

All Articles