1.1 --- a/docs/JavaServlet/NOTES.txt Thu Sep 27 17:48:43 2007 +0000
1.2 +++ b/docs/JavaServlet/NOTES.txt Thu Sep 27 22:32:20 2007 +0000
1.3 @@ -22,20 +22,21 @@
1.4 deploy the directory in the servlet container. For example:
1.5
1.6 jython webstack_java_build.py examples/JavaServlet/SimpleApp.py \
1.7 - examples/Common/Simple/ \
1.8 . \
1.9 /tmp/jython-cache \
1.10 web.xml \
1.11 + examples/Common/Simple/ \
1.12 + --libraries \
1.13 $CATALINA_HOME/common/lib/activation.jar \
1.14 $CATALINA_HOME/common/lib/mail.jar
1.15
1.16 -This identifies the handler (SimpleApp.py), the application package (Simple),
1.17 -the directory where the WebStack package is found (.), the directory to be
1.18 -used for caching imported classes, and the name of the template for the
1.19 -deployment descriptor (web.xml); it also specifies the library files which
1.20 -must also be deployed with the application (activation.jar and mail.jar from
1.21 -the Tomcat libraries in this case); it produces a directory called SimpleApp
1.22 -in the current directory.
1.23 +This identifies the handler (SimpleApp.py), the directory where the WebStack
1.24 +package is found (.), the directory to be used for caching imported classes,
1.25 +and the name of the template for the deployment descriptor (web.xml); it also
1.26 +specifies the package directories for the application (Simple), and after the
1.27 +--libraries flag, the library files which must also be deployed with the
1.28 +application (activation.jar and mail.jar from the Tomcat libraries in this
1.29 +case); it produces a directory called SimpleApp in the current directory.
1.30
1.31 Important
1.32 ---------
1.33 @@ -57,6 +58,24 @@
1.34
1.35 http://localhost:8080/SimpleApp/
1.36
1.37 +Running Applications with Apache Tomcat
1.38 +=======================================
1.39 +
1.40 +Before starting Tomcat, make sure the following environment variables are set:
1.41 +JAVA_HOME, CATALINA_HOME. On some systems, such as Ubuntu Feisty (7.04), even
1.42 +if Jython is installed (see above), there is no guarantee that a suitable Java
1.43 +development kit (JDK) will have been installed, yet Tomcat will require a JDK
1.44 +to function. It is therefore necessary to install the Sun JDK or a suitable
1.45 +package (eg. java-gcj-compat-dev). Then, the environment variables can be set
1.46 +up as in this example:
1.47 +
1.48 +export JAVA_HOME=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0
1.49 +export CATALINA_HOME=/home/paulb/Software/Java/jakarta-tomcat-4.1.31
1.50 +
1.51 +Generally, the contents of the directory referenced by JAVA_HOME should
1.52 +contain bin and lib directories, with the bin directory containing javac and
1.53 +other tools.
1.54 +
1.55 Authentication/Authorisation with Apache Tomcat
1.56 ===============================================
1.57
2.1 --- a/tools/JavaServlet/webstack_java_build.py Thu Sep 27 17:48:43 2007 +0000
2.2 +++ b/tools/JavaServlet/webstack_java_build.py Thu Sep 27 22:32:20 2007 +0000
2.3 @@ -75,13 +75,14 @@
2.4 def get_appname(handler):
2.5 return os.path.split(os.path.splitext(handler)[0])[1]
2.6
2.7 -def make_app(handler, appdir, webstack_home, jython_cachedir, web_xml_template_name):
2.8 +def make_app(handler, webstack_home, jython_cachedir, web_xml_template_name, packages):
2.9
2.10 """
2.11 - Make the application directory from the given 'handler', application
2.12 - directory 'appdir', the 'webstack_home' where the WebStack package can be
2.13 - found, the 'jython_cachedir' where Jython classes are cached, and the
2.14 - deployment descriptor with the given 'web_xml_template_name'.
2.15 + Make the application directory from the given 'handler', the 'webstack_home'
2.16 + where the WebStack package can be found, the 'jython_cachedir' where Jython
2.17 + classes are cached, the deployment descriptor with the given
2.18 + 'web_xml_template_name', and the specified 'packages' (locations of
2.19 + application packages).
2.20 """
2.21
2.22 appname = get_appname(handler)
2.23 @@ -108,9 +109,10 @@
2.24 copy_directory(os.path.join(webstack_home, "WebStack"),
2.25 os.path.join(appname, "WEB-INF", "jython"))
2.26
2.27 - # Copy the application itself.
2.28 + # Copy the application packages.
2.29
2.30 - copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython"))
2.31 + for appdir in packages:
2.32 + copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython"))
2.33
2.34 # Copy the handler.
2.35
2.36 @@ -148,30 +150,53 @@
2.37 import sys
2.38 if len(sys.argv) < 5:
2.39 print "Please specify..."
2.40 - print " * The location of the application handler."
2.41 - print " eg. .../WebStack-x.y/examples/JavaServlet/SimpleApp.py"
2.42 - print " * The location of the application."
2.43 - print " eg. .../WebStack-x.y/examples/Common/Simple"
2.44 - print " * The location of the WebStack package distribution or where"
2.45 - print " WebStack documentation and extras have been installed."
2.46 - print " eg. .../WebStack-x.y"
2.47 - print " eg. /usr/share/doc/python2.4-webstack"
2.48 - print " * The location of the Jython cache directory."
2.49 - print " eg. /home/paulb/.jython-cache"
2.50 - print " * The name of the deployment descriptor template."
2.51 - print " eg. web.xml"
2.52 - print "You can also specify some additional libraries for the application..."
2.53 - print " eg. $CATALINA_HOME/common/lib/activation.jar"
2.54 - print " $CATALINA_HOME/common/lib/mail.jar"
2.55 + print
2.56 + print "The location of the application handler. For example:"
2.57 + print
2.58 + print " .../WebStack-x.y/examples/JavaServlet/SimpleApp.py"
2.59 + print
2.60 + print "The location of the WebStack package distribution or where WebStack"
2.61 + print "documentation and extras have been installed. For example:"
2.62 + print
2.63 + print " .../WebStack-x.y"
2.64 + print " /usr/share/doc/python2.4-webstack"
2.65 + print
2.66 + print "The location of the Jython cache directory. For example:"
2.67 + print
2.68 + print " /home/paulb/.jython-cache"
2.69 + print
2.70 + print "The name of the deployment descriptor template. For example:"
2.71 + print
2.72 + print " web.xml"
2.73 + print
2.74 + print "The location of the application packages. For example:"
2.75 + print
2.76 + print " .../WebStack-x.y/examples/Common/Simple"
2.77 + print
2.78 + print "You can also specify some additional libraries for the application"
2.79 + print "after a special '--libraries' marker. For example:"
2.80 + print
2.81 + print " $CATALINA_HOME/common/lib/activation.jar"
2.82 + print " $CATALINA_HOME/common/lib/mail.jar"
2.83 sys.exit(1)
2.84
2.85 + handler, webstack_home, jython_cachedir, web_xml = sys.argv[1:5]
2.86 +
2.87 + try:
2.88 + libraries_index = sys.argv.index("--libraries")
2.89 + packages = sys.argv[5:libraries_index]
2.90 + libraries = sys.argv[libraries_index+1:]
2.91 + except ValueError:
2.92 + packages = sys.argv[5:]
2.93 + libraries = []
2.94 +
2.95 print "Making application directory..."
2.96 - make_app(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
2.97 + make_app(handler, webstack_home, jython_cachedir, web_xml, packages)
2.98
2.99 - if len(sys.argv) > 6:
2.100 + if libraries:
2.101 print "Copying additional libraries..."
2.102 appname = get_appname(sys.argv[1])
2.103 - for library in sys.argv[6:]:
2.104 + for library in libraries:
2.105 library_dir, library_name = os.path.split(library)
2.106 library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
2.107 copy_file(library, library_dest)