views:

669

answers:

3

I have installed Tomcat5 on CentOS 5 using the yum configuration tool. My java web application requires java 1.6 to run without errors. However, my tomcat install appears to be using java 1.4. This is confirmed when I navigate to the tomcat manager page:

Tomcat Version      JVM Version
Apache Tomcat/5.5.23    1.4.2

At the linux prompt, when I execute the command:

java -version

It reveals:

java version "1.6.0"
OpenJDK  Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)

I modifyied /etc/profile and setting JAVA_HOME, JRE_HOME, and CATALINA_HOME. When I execute tomcat5 version the following output results:

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/jre-1.6.0
Server version: Apache Tomcat/5.5.23
Server built:   Jul 27 2009 05:24:08
Server number:  5.5.23.0
OS Name:        Linux
OS Version:     2.6.18-128.1.6.el5
Architecture:   amd64
JVM Version:    1.6.0-b09
JVM Vendor:     Sun Microsystems Inc.

However, when I start tomcat and view the server information the JVM still says:

 JVM version 1.4.2

Any help is appreciated.

Thanks,

A: 

If it is a regular Tomcat installation and you are not using any CentOS or yum specific scripts, you can set JAVA_HOME in bin/startup.sh (located in the Tomcat installation directory) to the installation directory of Java 6. This should force Tomcat to use the correct JDK installation.

jarnbjo
I installed via Tomcat5 via yum. When I navigate to the tomcat install directory there isn't a startup.sh in the bin directory.Tomcat is being run as a service. any ideas?
LB
+2  A: 

It looks like many people (both on CentOS and other platforms) have trouble with the yum-installed version of tomcat. I tried installing it myself, and tend to agree - it looks pretty messy.

Like others in the above links, I would recommend removing the yum version and downloading the tarball version straight from http://tomcat.apache.org/. I use this method for all of my tomcat installations (quite frequent), and have had few problems with this approach.

You can extract the tarball wherever you deem appropriate for your system (perhaps /opt), and start it up using the startup.sh script in the bin/ directory. It should obey environment variables better than the yum version, but you can also set them in one of the properties files or scripts delivered with the application.

Rob Hruska
Rob,Thanks for the suggestion. I attempted this with tomcat 6. However, when i attempted to run startup.sh my terminal crashes everytime.
LB
That's strange, I can't say I've ever seen that. Does it do the same thing with tomcat5?
Rob Hruska
@LB Debug your installation with `${CATALINA_HOME}/bin/catalina.sh run`. This will run Tomcat command as a foreground process, so you can see all the diagnostic messages in real time in your console window.
Alexander Pogrebnyak
@Alexander @Rob I am attempting with tomcat55. Whether I run catalina.sh or startup.sh the terminal windows immediately crashes.
LB
@LB - What happens if you start it, debugging it like Alexander described, but redirecting the output to a file? Can you go back and read that file in a new terminal? Does it contain anything useful?
Rob Hruska
@Alexander @Rob. You guys are geniuses. When I ran the process in the foreground, it revealed that the JAVA_HOME and JRE_HOME paths were not being read. I edited my catalina.sh file to ensure that tomcat knew the values for the env variable. Once I did that and started tomcat55, I verified that my java version was 1.6.
LB
@LB - Nice, glad to see you got it working. For reference, was this with the standalone tomcat or the yum-installed one?
Rob Hruska
This was the standalone tomcat. There was no catalina.sh for the yum installed version. Seems like it could only run as a service.Thanks again.
LB
If this worked for you, you can click the checkmark on the left to accept the answer. This will let others know that it worked for you. You should probably also accept the top answer to your other question, since it worked for you as well: http://stackoverflow.com/questions/1494416/issue-parsing-xml-document-using-saxparser-2047-character-limit/1494468#1494468
Rob Hruska
A: 

Hi,

try to edit the /usr/bin/dtomcat5 script.

Thomas Muench