# HG changeset patch # User paulb # Date 1190932340 0 # Node ID 17cf1ce93b8218a9d48dc07e6e69f4754b04b970 # Parent e1211a95a44fe0cba160e6fc71a5160ff8b4276f [project @ 2007-09-27 22:32:18 by paulb] Improved the Java deployment documentation and tools. diff -r e1211a95a44f -r 17cf1ce93b82 docs/JavaServlet/NOTES.txt --- a/docs/JavaServlet/NOTES.txt Thu Sep 27 17:48:43 2007 +0000 +++ b/docs/JavaServlet/NOTES.txt Thu Sep 27 22:32:20 2007 +0000 @@ -22,20 +22,21 @@ deploy the directory in the servlet container. For example: jython webstack_java_build.py examples/JavaServlet/SimpleApp.py \ - examples/Common/Simple/ \ . \ /tmp/jython-cache \ web.xml \ + examples/Common/Simple/ \ + --libraries \ $CATALINA_HOME/common/lib/activation.jar \ $CATALINA_HOME/common/lib/mail.jar -This identifies the handler (SimpleApp.py), the application package (Simple), -the directory where the WebStack package is found (.), the directory to be -used for caching imported classes, and the name of the template for the -deployment descriptor (web.xml); it also specifies the library files which -must also be deployed with the application (activation.jar and mail.jar from -the Tomcat libraries in this case); it produces a directory called SimpleApp -in the current directory. +This identifies the handler (SimpleApp.py), the directory where the WebStack +package is found (.), the directory to be used for caching imported classes, +and the name of the template for the deployment descriptor (web.xml); it also +specifies the package directories for the application (Simple), and after the +--libraries flag, the library files which must also be deployed with the +application (activation.jar and mail.jar from the Tomcat libraries in this +case); it produces a directory called SimpleApp in the current directory. Important --------- @@ -57,6 +58,24 @@ http://localhost:8080/SimpleApp/ +Running Applications with Apache Tomcat +======================================= + +Before starting Tomcat, make sure the following environment variables are set: +JAVA_HOME, CATALINA_HOME. On some systems, such as Ubuntu Feisty (7.04), even +if Jython is installed (see above), there is no guarantee that a suitable Java +development kit (JDK) will have been installed, yet Tomcat will require a JDK +to function. It is therefore necessary to install the Sun JDK or a suitable +package (eg. java-gcj-compat-dev). Then, the environment variables can be set +up as in this example: + +export JAVA_HOME=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0 +export CATALINA_HOME=/home/paulb/Software/Java/jakarta-tomcat-4.1.31 + +Generally, the contents of the directory referenced by JAVA_HOME should +contain bin and lib directories, with the bin directory containing javac and +other tools. + Authentication/Authorisation with Apache Tomcat =============================================== diff -r e1211a95a44f -r 17cf1ce93b82 tools/JavaServlet/webstack_java_build.py --- a/tools/JavaServlet/webstack_java_build.py Thu Sep 27 17:48:43 2007 +0000 +++ b/tools/JavaServlet/webstack_java_build.py Thu Sep 27 22:32:20 2007 +0000 @@ -75,13 +75,14 @@ def get_appname(handler): return os.path.split(os.path.splitext(handler)[0])[1] -def make_app(handler, appdir, webstack_home, jython_cachedir, web_xml_template_name): +def make_app(handler, webstack_home, jython_cachedir, web_xml_template_name, packages): """ - Make the application directory from the given 'handler', application - directory 'appdir', the 'webstack_home' where the WebStack package can be - found, the 'jython_cachedir' where Jython classes are cached, and the - deployment descriptor with the given 'web_xml_template_name'. + Make the application directory from the given 'handler', the 'webstack_home' + where the WebStack package can be found, the 'jython_cachedir' where Jython + classes are cached, the deployment descriptor with the given + 'web_xml_template_name', and the specified 'packages' (locations of + application packages). """ appname = get_appname(handler) @@ -108,9 +109,10 @@ copy_directory(os.path.join(webstack_home, "WebStack"), os.path.join(appname, "WEB-INF", "jython")) - # Copy the application itself. + # Copy the application packages. - copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython")) + for appdir in packages: + copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython")) # Copy the handler. @@ -148,30 +150,53 @@ import sys if len(sys.argv) < 5: print "Please specify..." - print " * The location of the application handler." - print " eg. .../WebStack-x.y/examples/JavaServlet/SimpleApp.py" - print " * The location of the application." - print " eg. .../WebStack-x.y/examples/Common/Simple" - print " * The location of the WebStack package distribution or where" - print " WebStack documentation and extras have been installed." - print " eg. .../WebStack-x.y" - print " eg. /usr/share/doc/python2.4-webstack" - print " * The location of the Jython cache directory." - print " eg. /home/paulb/.jython-cache" - print " * The name of the deployment descriptor template." - print " eg. web.xml" - print "You can also specify some additional libraries for the application..." - print " eg. $CATALINA_HOME/common/lib/activation.jar" - print " $CATALINA_HOME/common/lib/mail.jar" + print + print "The location of the application handler. For example:" + print + print " .../WebStack-x.y/examples/JavaServlet/SimpleApp.py" + print + print "The location of the WebStack package distribution or where WebStack" + print "documentation and extras have been installed. For example:" + print + print " .../WebStack-x.y" + print " /usr/share/doc/python2.4-webstack" + print + print "The location of the Jython cache directory. For example:" + print + print " /home/paulb/.jython-cache" + print + print "The name of the deployment descriptor template. For example:" + print + print " web.xml" + print + print "The location of the application packages. For example:" + print + print " .../WebStack-x.y/examples/Common/Simple" + print + print "You can also specify some additional libraries for the application" + print "after a special '--libraries' marker. For example:" + print + print " $CATALINA_HOME/common/lib/activation.jar" + print " $CATALINA_HOME/common/lib/mail.jar" sys.exit(1) + handler, webstack_home, jython_cachedir, web_xml = sys.argv[1:5] + + try: + libraries_index = sys.argv.index("--libraries") + packages = sys.argv[5:libraries_index] + libraries = sys.argv[libraries_index+1:] + except ValueError: + packages = sys.argv[5:] + libraries = [] + print "Making application directory..." - make_app(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) + make_app(handler, webstack_home, jython_cachedir, web_xml, packages) - if len(sys.argv) > 6: + if libraries: print "Copying additional libraries..." appname = get_appname(sys.argv[1]) - for library in sys.argv[6:]: + for library in libraries: library_dir, library_name = os.path.split(library) library_dest = os.path.join(appname, "WEB-INF", "lib", library_name) copy_file(library, library_dest)