0

I was running Tomcat 5.5.23 on centOS 5.5 then had to reinstall for some reason. After installation it will not start. Checking the catalina.out file resulted in this error. Googling for a few hours showed the result was to copy the missing jar file into a directory (/var/lib/tomcat5/server/lib) which solved the problem but however created another one; this time I'm getting the following error:

Using CATALINA_BASE:   /usr/share/tomcat5
Using CATALINA_HOME:   /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
Using JRE_HOME:       /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64
java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/SystemLogHandler
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2406)
        at java.lang.Class.getConstructor0(Class.java:2716)
        at java.lang.Class.newInstance0(Class.java:343)
        at java.lang.Class.newInstance(Class.java:325)
        at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:225)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:410)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.log.SystemLogHandler
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
        ... 7 more

I have been Googling for hours to no end and I suspect this isn't a "copying jar files into a directory problem" but rather a set environment variable problem, but the problem is that I'm not sure where to set said variable. Although there is no CLASSPATH variable defined for the system, (I believe this gets created in the startup script) but everything in the tomcat5.conf is set correctly. Any help would be appreciated. The closest similar issue I found was by this guy on the Tomcat mailing list but as you can see it's a few years old.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Dark Star1
  • 6,986
  • 16
  • 73
  • 121
  • I saw your proposed edit of Alain's answer - and rejected it. What I think you should do is edit your question, copying up the relevant information from the answer and comments. I'd start with a horizontal rule and a `### Summary of Answer` to bring the important information to better visibility. Alternatively, Alain could edit his answer to bring the relevant comments into the main material. Either, or both, would make it easier for those who come later to find the information. – Jonathan Leffler Feb 20 '11 at 16:10

1 Answers1

0

First thing to check is that you have tomcat-util jar under /usr/share/tomcat5/server/lib

I notice that you mention /var/lib/tomcat/server/lib whereas the catalina.out says CATALINA_HOME equates to /usr/share/tomcat5 which is way more standard.

You need to make sure that the server tree is correctly deployed under /usr/share/tomcat5 if this is what CATALINA_HOME is set to.

Did you install as RPM or just untaring the tarball` from the apache download site ?

DO you start tomcat with /usr/share/tomcat5/bin/startup.sh ? Or with a less standard procedure ?

In the end what you need is something like

java 
  -classpath /usr/share/tomcat5/bin/bootstrap.jar
  -Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS
  -Dcatalina.base="$CATALINA_BASE"
  -Dcatalina.home="$CATALINA_HOME"
  -Djava.io.tmpdir="$CATALINA_TMPDIR"
   org.apache.catalina.startup.Bootstrap

And these variables might be defined in /etc/environment (assuming redhat/centos are not different in this than debian) or only a shell script wrapping startup.sh or catalina.sh

Alain Pannetier
  • 9,315
  • 3
  • 41
  • 46
  • the only thing in that location is the catalina.jar file I copied to it. As for for the CATALINA_HOME variable that's set to the /usr/share/tomcat5 directory path (which in itself contains links to the /var/lib... directory path. – Dark Star1 Feb 19 '11 at 16:16
  • Then for some reason, you miss a number of jars in the /var/lib/tomcat/server/lib. To make sure, I would download the whole tarball from apache tomcat 5.5 and explode it under the /var/lib/tomcat if that's where the symlink points at. – Alain Pannetier Feb 19 '11 at 16:18
  • Hm, wait. Only the server/lib folder for now. There might be important stuff under conf, shared, webapps etc... – Alain Pannetier Feb 19 '11 at 16:25
  • So go ahead. Since you said CentOs I suddenly thought you might be in "prod". I do not know how you installed, RPM or manually. I'd go for manual because upgrades are to be made with care. Basically, fetch the latest [tarball](http://tomcat.apache.org/download-55.cgi#5.5.33) (5.5.33) and gunzip-pipe-untar it under your catalina home. You should be fine. – Alain Pannetier Feb 19 '11 at 16:55
  • I kind f need to work with the 5.5.23 version In order to mirror the production server. Which happens to be the latest from the CentOS repos – Dark Star1 Feb 19 '11 at 16:59
  • I understand. No prob. Use [http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.23/bin/](http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.23/bin/) instead then. Select the `apache-tomcat-5.5.23.tar.gz` bundle then (2007-03-08 21:15 5.7M). I've checked you startup file, its basically an old version of catalina.sh. Once you've downloaded the tarball, do a diff between your dtomcat5 and the catalina.sh in bin to see whether there are any meaningful differences. – Alain Pannetier Feb 19 '11 at 17:13
  • THANKS!! I'll let you know how it went – Dark Star1 Feb 19 '11 at 17:16
  • before I exploded the tar I decided to compare the directory structure to the production and noticed that what was in the /var/lib/tomcat5 folder are links to jars in the /usr/share/java/ directory tree. Somehow these links aren't being created in the /var/lib/tomcat5 folder during installation – Dark Star1 Feb 19 '11 at 18:02
  • I've noticed you used openJdk. I stuck to the Sun JVM, so I can't be 100% sure they would map if you gave me the link. However, you can safely reproduce these links. There is no reason why these links would be re-created during the untar; Tomcat comes standalone. However, the folks who devised this mechanism in your prod environment, probably knew well what they wanted. If this is not too long, just give me a sample. Tomcat often needs some tweaking for infrastructure stuff such as logging, jdbc drivers, jmx, ldap, jaas, etc... – Alain Pannetier Feb 19 '11 at 18:11
  • All this makes sense, you can replicate this. If you already have these files in the /usr/share/java, just do the `ln -s` accordingly otherwise, complete with what you have in prod or from the tarball. Any questions regarding one of these, please ask. – Alain Pannetier Feb 19 '11 at 18:44
  • Thanks very much Will let you know how it goes after I fixed the accident I had with the production server :/ – Dark Star1 Feb 19 '11 at 18:47
  • Muchas gracias senor. You really helped. I had to create links in both and to get tomcat started. A note for anyone who has similar problems is to copy the *.renametojar files from the exploded tomcat5 tar.gz (link Alain gave me) to the /var/lib/tomcat5/server/lib directory along with creating the required links. – Dark Star1 Feb 20 '11 at 15:29