Tomcat on Linux (centos). Incorrect java version
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 开发者_JAVA技巧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,
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.
try to set JAVA_HOME in /etc/sysconfig/tomcat5
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.
try to edit the /usr/bin/dtomcat5
script.
精彩评论