Tomcat Setup

This describes setting up Tomcat WebServletFramework.

Documentation

Installation

Enable Tomcat application management and administration web interfaces by modifying tomcat-users.xml in /var/lib/tomcat5.5/conf/:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="$USER" password="$PASSWORD" roles="admin,manager,tomcat"/>
</tomcat-users>

Here, $USER and $PASSWORD should be substituted with a name and password to be presented to Tomcat.

The Ubuntu Tomcat package listens for HTTP requests on port 8180,

The "Status", "Tomcat Administration" and "Tomcat Manager" links in the top left corner will require the above user name and password.

JSP

The tomcat5.5 package in Ubuntu as well as Debian requires some fiddling to pre-process ("compile") JSP pages into Java code. The following symptoms indicate bad packaging:

  • Error:
Missing taglibs (JSTL).
  • Cause: JSTL jars need to be downloaded from Jakarta Taglibs web site and copied to the endorsed Tomcat directory.

  • Error:
no jsp servlet
  • Cause: jasper-compiler.jar is missing from /usr/share/tomcat5.5/commons/endorsed/, along with many other JARs found in ../lib/.

  • Error:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
        at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:53)
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
        at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
        ... 4 more
Caused by: java.lang.NullPointerException
        at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
        ... 5 more
  • Cause: A recent (1.1) version of Commons Logging is required, not the one packaged with libcommons-logging-java (1.0.4).

The Adjustments

cd ~/download
wget http://gulus.usherbrooke.ca/pub/appl/apache/commons/logging/source/commons-logging-1.1-src.tar.gz
tar xvzf commons-logging-1.1-src.tar.gz
cd /usr/share/tomcat5.5/common/endorsed/
# Use the Commons Logging v. 1.1 rather than the packaged 1.0.4.
# Otherwise the above null pointer exception in getLogConstructor will occur.
sudo cp -a ~/download/commons-logging-1.1/commons-logging-1.1.jar .

# Set the factory to Jdk14Logger so that web apps compiled against JCL could 
# channel their output through java.util.logging.  Add this to JAVA_OPTS in 
# /etc/default/tomcat5.5:

   -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger

# Download the JSTL JARs from Jakarta Taglibs,
#
#   http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
#
#(jstl.jar and standard.jar), copy them to 
# /usr/local/share/java/.  (I do not know why these JARs are not packaged by
# Debian).

# Download the "JDK compatibility" JARs from Apache Tomcat and copy 
# xml-apis.jar to /usr/local/share/java/.

sudo apt-get install libxalan2-java
for f in \
         commons-collections3.jar commons-dbcp.jar commons-el.jar \
         commons-pool.jar jasper-compiler.jar jasper-compiler-jdt.jar \
         jasper-runtime.jar \
         jsp-api.jar  servlet-api.jar \
         naming-factory.jar naming-resources.jar \
         serializer.jar xalan2.jar xercesImpl.jar \
   ; do
   sudo rm $f
   sudo ln -s /usr/share/java/$f .
done
for f in \
         jstl.jar standard.jar xml-apis.jar \
   ; do
   sudo rm $f
   sudo ln -s /usr/local/share/java/$f .
done

Cluster

The cluster setup does not involve a J2EE application server.

1. Tomcat FAQ. Cluster.

Other articles explain the internals and management of Tomcat clusters.

2. Session Replication in Tomcat 5 Clusters, Part 2, by Srini Penchikala, 12/15/2004.

3. Clustering and Load Balancing in Tomcat 5, Part 2, by Srini Penchikala, 04/14/2004. 4. Remotely monitor Tomcat clusters using MC4J, By Srini Penchikala, JavaWorld.com, 08/01/05. -- IlguizLatypov - 10 Jul 2007
Topic revision: r5 - 2013-08-16 - DrewPilcher
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback