JSDK, JDK and GNUJSP
Installing the JSDK, JDK and GNUJSP first will help later on when you try to reference their installation directories in the JServ configuration. The only requirement for installing these packages is that they absolutely must be accessible by the user your Web server runs as, which is generally nobody or apache.
Make sure the JVM runs on your OS. We installed it on two separate machines and had problems with running both the JDK 1.2 and JDK 1.3 JVM on the second machine. We could not get the JDK 1.2 running on the second machine, but we were able to discover that the problem with JDK 1.3 was due to a missing shared library. To check for that library, just change to the $JDK_HOME/bin directory and run "java". If it runs, you're well on your way. If not, you may need to try a different version of the JDK (JServ will run with JDK 1.1.x and above) or acquire the proper shared libraries, if there any missing.
Static Build
If you decide to compile JServ support into Apache, the JServ build process will compile the classes which make up Jserv, package them in a jar file, and then copy them to the specified directory. Here's a typical configuration for building JServ into Apache.
./configure \
--prefix=/usr/local/jserv \
--with-apache-src=/usr/local/apache/source \
--with-jdk-home=/path/to/jdk \
--with-JSDK=/path/to/jsdk.jar \
--disable-debugging
If you are using mod_ssl, you also need to build using the EAPI (extendend API), which provides hook in Apache for SSL support, with the following directive.
--enable-EAPI
The documentation and the Apache JServ .jar file will be installed into the directory denoted within the ęprefix directive. You can change this as desired. Once JServ has compiled correctly, you need to run make install in order to move the files into the proper directories and then recompile Apache. When we ran make install, the Apache configuration file was updated automatically to include the activation of the JServ module. In case it does not work automatically with make install in your environment, you can use this configuration.
./configure \
--prefix=/usr/local/apache
--activate-module=src/modules/jserv/libjserv.a
make install
Dynamic Build
If you choose to build a DSO module of JServ for use with Apache, the JServ build process will create a shared object and the JServ jar file. The DSO configuration for JServ generally looks like this:
./configure \
--prefix=/usr/local/jserv \
--with-apxs=/usr/local/apache/bin/apxs \
--with-jdk-home=/path/to/jdk \
--with-JSDK=/path/to/jsdk.jar \
--disable-debugging
Once the compilation has finished, the script should install automatically within the correct directories by calling make install. If the script fails to run the install portion, you'll need to call it yourself.
Configuration of JServ and JSP support
There are three different configuration files for Apache JServ. They cascade, each reading the next in turn. These files also will be modified to configure support for JSPs.
httpd.conf -> jserv.conf -> jserv.properties -> .properties
In all three cases, it is imperative that the user under which you run your Web server is able to read these files. The first one, jserv.conf, should be included in your httpd.conf file with the Apache "Include" directive. For example, in your httpd.conf file, you should have a line like this:
"Include /path/to/jserv.conf"
In the jserv.conf file, you will need to include the following command:
ApJServProperties /path/to/jserv.properties
Also, find the line in jserv.conf containing ApJServLogFile. If the JVM process cannot write to the file this variable points to, JServ will not run correctly. I finally tracked this tricky problem down after observing that the JVM continually started and died.
It is a good idea to read through jserv.properties, as it contains many tidbits and guidelines for files and settings that are necessary for Jserv and the JVM to run, which are not documented in the HOWTO on JServ's Web site. Also contained in this file are the mount points for both servlets and JSPs, as well as the action handler needed to tell Apache what to do with .jsp files. I created /servlets and /servlet for general servlet use, as well as /test for JSP files.
The first "parameter" for a mount point in the jserv.conf file defines the mount point, which will be used to invoke servlets on your site. It will look like this:
http://domainname.com/servlets/nameofservlet.
The zone defines a collection of servlets and will be used in the jserv.properties file to load a properties file containing zone specific information, such as physical location of servlets and classes.
ApJServMount /servlets /root
ApJServMount /servlet /root
ApJServMount /test /test
The following sets up the action handler for JSPs:
ApJServAction .jsp /test/gnujsp
This tells Apache that a servlet aliased as "gnujsp" in the zone test should be called in order to handle any file with the extension .jsp.
The jserv.properties file is where you really define the information necessary to setup Jserv and in turn start delivering JSPs. Although the install should have modified this file to include the necessary information, double check it to make sure the following line exists.
wrapper.bin=/path/to/jdk/java
This line indicates where to invoke the JVM from and must be correct in order to support servlets and JSPs. The following lines set up the java classpath variable, which needs to know where to find the necessary jar files.
wrapper.classpath=/path/to/ApacheJServ.jar
wrapper.classpath=/path/to/jsdk/lib/jsdk.jar
wrapper.classpath=/path/to/jdk/lib/tools.jar
wrapper.classpath=/path/to/jre/lib/rt.jar
You could add the JSP jar files here, but it is unnecessary to add this to calls for servlets. We'll simply add the JSP jar files in the zone file that we'll create to handle JSPs.
To finalize these settings, you'll need to tell JServ to load the property files you created for each zone zone you defined in jserv.conf like so:
zones=root,test
root.properties = /path/to/root.properties
test.properties = /path/to/test.properties
We'll ignore root.properties for now, and go directly to test.properties, which will define our JSP support settings.
If you have any comments on or questions about this article, please message Lori MacVittie at lori@nandgate.com.
Page 1 | 2 | 3 | Next page