Configuring Tomcat

If you plan to access JOnAS from a Java client without going through a Web server and a JSP/Servlet server, you can skip this section and directly jump to the section called Configuring JOnAS. Else you will have to setup your environment variables and use the appropriate Tomcat options for startup.

Environment variables setting

You must define the TOMCAT_HOME environment variable to the directory where you installed Tomcat. The process is similar to the one to set the JAVA_HOME environment variable (see the section called Setting up your Java environment). Here are examples for Unix and Windows platforms:

Starting Tomcat with JOnAS/RMI

Before starting Tomcat, you have to run the config_env script that automatically sets your CLASSPATH correctly. Then you have to specify on which machine JOnAS RMI registry will run, so that Tomcat will be able to contact it. Here is an example showing how to start Tomcat if JOnAS is running on nodex.rice.edu using RMI:

bash>. $JONAS_ROOT/bin/unix/config_env
bash>export TOMCAT_OPTS = \
  "-Djava.naming.provider.url=rmi://nodex.rice.edu:1099 \
   -Djava.naming.factory.initial= \
       com.sun.jndi.rmi.registry.RegistryContextFactory \
   -Djava.naming.factory.url.pkgs=org.objectweb.jonas.naming"
bash>$TOMCAT_HOME/bin/tomcat.sh start
        

Starting Tomcat with JOnAS/Jeremie

Before starting Tomcat, you have to run the config_env script that automatically sets your CLASSPATH correctly. Then you have to specify on which machine Jeremie will run, so that Tomcat will be able to contact it. Here is an example showing how to start Tomcat if Jeremie is running on nodex.rice.edu:

bash>. $JONAS_ROOT/bin/unix/config_env
bash>export TOMCAT_OPTS = \
  "-Djava.naming.provider.url=jrmi://nodex.rice.edu:12340 \
   -Djava.naming.factory.initial= \
       org.objectweb.jeremie.libs.services.registry.jndi.JRMIInitialContextFactory \
   -Djava.naming.factory.url.pkgs=org.objectweb.jonas.naming"
bash>$TOMCAT_HOME/bin/tomcat.sh start
        

Large number of servlets in Tomcat

The default Tomcat configuration only allows a few number of servlets to be run in parallel. However, you can easily set a larger number of conccurent servlets in the $TOMCAT_HOME/conf/server.xml file. Here is an example allowing 1024 servlets without security (AJP12) and 512 servlets with security (AJP13):

<!-- Apache AJP12 support.  >
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
   <Parameter name="handler" 
  value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
   <Parameter name="port" value="8007"/>
   <Parameter name="max_threads" value="1024"/>
   <Parameter name="min_spare_threads" calue="5"/>
   <Parameter name="max_spare_threads" calue="20"/>
</Connector>

<!-- Apache AJP13 support.  >
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
   <Parameter name="handler" 
  value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/>
   <Parameter name="port" value="8009"/>
   <Parameter name="max_threads" value="512"/>
   <Parameter name="min_spare_threads" calue="5"/>
   <Parameter name="max_spare_threads" calue="20"/>
</Connector>

You must be careful when allowing a large number of servlets because the performance of your servlet server can collapse when overloaded. Moreover, it is more likely that you will run out of memory with the standard JVM settings. You can reduce the risk of running out of memory by setting a larger heap size and reducing the stack size of each thread. Here is an example setting heap size to 512MB and stack size to 64KB for Tomcat:

bash>export TOMCAT_OPTS=${TOMCAT_OPTS}" -Xmx512m -Xss64k"