Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat JVM version different from JAVA_HOME

Tags:

java

tomcat

I wanted to make my Tomcat JVM version be 7. So I followed in the instruction here: How to change Java version used by TOMCAT? and changed my JAVA_HOME to be my jdk7 directory.

To make sure, here is the command:

$ echo $JAVA_HOME 
/usr/lib/jvm/java-7-openjdk-amd64

I restarted Tomcat. I wanted to verify, and ran the command I got from here: https://stackoverflow.com/a/10822328/998318

$ /usr/share/tomcat7/bin/catalina.sh version
/usr/share/tomcat7/bin/catalina.sh: 1: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote: not found
/usr/share/tomcat7/bin/catalina.sh: 2: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote.port=1099: not found
/usr/share/tomcat7/bin/catalina.sh: 3: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote.authenticate=false: not found
/usr/share/tomcat7/bin/catalina.sh: 4: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote.ssl=false: not found
Using CATALINA_BASE:   /usr/share/tomcat7
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME:        /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.28
Server built:   Apr 8 2014 08:47:08
Server number:  7.0.28.0
OS Name:        Linux
OS Version:     3.16.0-0.bpo.4-amd64
Architecture:   amd64
JVM Version:    1.7.0_79-b14
JVM Vendor:     Oracle Corporation

and indeed I see that JVM version is 1.7.0_79-b14

BUT when i go to the online manager I see this: enter image description here

what's going on? and indeed I started this whole process because my war isn't getting deployed because of a version mismatch:

Caused by: java.lang.UnsupportedClassVersionError: 
org/glassfish/jersey/servlet/init/JerseyServletContainerInitializer : 
Unsupported major.minor version 51.0 (unable to load class 
org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer)

update as requested, here is the output for running java -version:

$ java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-1~deb7u1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
like image 698
Moshe Shaham Avatar asked Sep 02 '15 10:09

Moshe Shaham


1 Answers

On *nix, create the setenv.sh file with the following content:

JRE_HOME=/usr/java/jdk1.7.0_03/jre
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
like image 93
SaviNuclear Avatar answered Oct 18 '22 09:10

SaviNuclear