Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when starting Tomcat, unsupported major/minor version, environment variables seem correct though

I'm having a problem starting Tomcat 7 from the command line on Linux, and the log shows this:

Sep 24, 2012 8:54:10 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the jav
a.library.path: /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/lib/amd64/server:/usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/lib/amd64:/u
sr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/../lib/amd64:/usr/lib64/mpi/gcc/openmpi/lib64:/usr/java/packages/lib/amd64:/usr/lib64:/lib6
4:/lib:/usr/lib
Sep 24, 2012 8:54:10 AM org.apache.tomcat.util.digester.Digester startElement
SEVERE: Begin event threw error
java.lang.UnsupportedClassVersionError: pms/security/BCryptRealm : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:144)
        at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:504)
        at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.jav
a:1320)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScann
erImpl.java:2732)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:48
8)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:525)
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:610)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:658)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)

From googling I understand the first bit I can just ignore, but I was wondering if that's indicative of the version of Java it's trying to use, since it keeps saying Java 6. The "Unsupported major.minor version 51.0" I understand means I have a problem with Java versions somehow.

I built the class it's having problems with (a custom realm to use BCrypt) using ant, and running ant -v shows it's compiling with Java 7, which is what I want. I've set JAVA_HOME and JDK_HOME to use Java 7 as well (they're all pointing to the same place as far as I can tell).

What else am I missing? If more info is needed let me know. I'd really appreciate any pointers on where I should look for whatever is going wrong. Thanks.

ETA a little more info per questions in comments: I'm starting tomcat via the command line. I just do ./bin/startup.sh from the tomcat base directory. I downloaded tomcat from the Apache website. I got the core tar.gz version and unpacked it just last night (I only had version 6 before and wanted to upgrade). Also this isn't my personal machine; I only have user rights, if that matters.

like image 629
Maltiriel Avatar asked Sep 24 '12 15:09

Maltiriel


3 Answers

Open tomcat/bin directory and change JAVA_HOME parmater in catalina.sh

like image 99
Ilya Avatar answered Nov 20 '22 14:11

Ilya


I dont think that given responses are correct. In fact, major.minor exception means that the current Java version you have installed does not match the minimum requirement. In particular, in your error says 51 (which is the internal code for Java SE 7). So to fix the issue you actually need to install Java 7.

like image 42
juancancela Avatar answered Nov 20 '22 14:11

juancancela


Ensure the JRE_HOME is set to JRE1.6 (or greater).

Also, just a gotcha. If you have two installations of Tomcat (i.e. Tomcat8 alongside Tomcat7), make sure your CATALINA_HOME variable isn't set to the Tomcat8's path. As this will also cause this issue. (I overlooked the logs at first!)

C:\devtools\apache-tomcat-7.0.47\bin>set CATALINA_HOME=C:\devtools\apache-tomcat-8.0.0-RC5

C:\devtools\apache-tomcat-7.0.47\bin>configtest.bat
Using CATALINA_BASE:   "C:\devtools\apache-tomcat-8.0.0-RC5"
Using CATALINA_HOME:   "C:\devtools\apache-tomcat-8.0.0-RC5"
Using CATALINA_TMPDIR: "C:\devtools\apache-tomcat-8.0.0-RC5\temp"
Using JRE_HOME:        "C:\Progra~1\Java\jdk1.6.0_45\jre\"
Using CLASSPATH:       "C:\devtools\apache-tomcat-8.0.0-RC5\bin\bootstrap.jar;C:\devtools\apache-tomcat-8.0.0-RC5\bin\tomcat-juli.jar"
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.catalina.startup.Bootstrap.  Program will exit.

Fyi, you can unset CATALINA_HOME by using:

set CATALINA_HOME=
like image 2
Nick Grealy Avatar answered Nov 20 '22 13:11

Nick Grealy