Tomcat ClassNotFoundException after switching from openjdk to sun java
We switched our java version from openjdk jre 1.7 to sun jre 1.7 and now starting tomcat gives the following errors:
SEVERE: Begin event threw error
java.lang.NoClassDefFoundError: org.apache.catalina.mbeans.ServerLifecycleListener
at java.lang.Class.initializeClass(libgcj.so.10)
at java.lang.Class.newInstance(libgcj.so.10)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:206)
at org.apache.tomcat.util.digester.Rule.begin(Rule.java:153)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1356)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642)
at org.apache.catalina.startup.Catalina.load(Catalina.java:524)
at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
at java.lang.reflect.Method.invoke(libgcj.so.10)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: javax.management.modelmbean.ModelMBeanNotificationBroadcaster not found in org.apache.catalina.loader.StandardClassLoader{urls=[file:/opt/apache-tomcat-6.0.35/lib/,file:/opt/apache-tomcat-6.0.35/lib/el-api.jar,file:/opt/apache-tomcat-6.0.35/lib/jasper-el.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-i18n-fr.jar,file:/opt/apache-tomcat-6.0.35/lib/jsp-api.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina.jar,file:/opt/apache-tomcat-6.0.35/lib/jasper.jar,file:/opt/apache-tomcat-6.0.35/lib/servlet-api.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina-tribes.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina-ha.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-dbcp.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-coyote.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-i18n-ja.jar,file:/opt/apache-tomcat-6.0.35/lib/ecj-3.7.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina-ant.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-i18n-es.jar,file:/opt/apache-tomcat-6.0.35/lib/annotations-api.jar], parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:/opt/apache-tomcat-6.0.35/bin/bootstrap.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.VMClassLoader.defineClass(libgcj.so.10)
at java.lang.ClassLoader.defineClass(libgcj.so.10)
at java.security.SecureClassLoader.defineClass(libgcj.so.10)
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.VMClassLoader.defineClass(libgcj.so.10)
at java.lang.ClassLoader.defineClass(libgcj.so.10)
at java.security.SecureClassLoader.defineClass(libgcj.so.10)
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.Class.forName(libgcj.so.10)
at java.lang.Class.initializeClass(libgcj.so.10)
...11 more
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(libgcj.so.10)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: org.apache.catalina.mbeans.ServerLifecycleListener
at java.lang.Class.initializeClass(libgcj.so.10)
at java.lang.Class.newInstance(libgcj.so.10)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:206)
at org.apache.tomcat.util.digester.Rule.begin(Rule.java:153)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1356)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642)
at org.apache.catalina.startup.Catalina.load(Catalina.java:524)
at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
at java.lang.reflect.Method.invoke(libgcj.so.10)
...2 more
Caused by: java.lang.ClassNotFoundException: javax.management.modelmbean.ModelMBeanNotificationBroadcaster not found in org.apache.catalina.loader.StandardClassLoader{urls=[file:/opt/apache-tomcat-6.0.35/lib/,file:/opt/apache-tomcat-6.0.35/lib/el-api.jar,file:/opt/apache-tomcat-6.0.35/lib/jasper-el.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-i18n-fr.jar,file:/opt/apache-tomcat-6.0.35/lib/jsp-api.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina.jar,file:/opt/apache-tomcat-6.0.35/lib/jasper.jar,file:/opt/apache-tomcat-6.0.35/lib/servlet-api.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina-tribes.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina-ha.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-dbcp.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-coyote.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-i18n-ja.jar,file:/opt/apache-tomcat-6.0.35/lib/ecj-3.7.jar,file:/opt/apache-tomcat-6.0.35/lib/catalina-ant.jar,file:/opt/apache-tomcat-6.0.35/lib/tomcat-i18n-es.jar,file:/opt/apache-tomcat-6.0.35/lib/annotations-api.jar], parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:/opt/apache-tomcat-6.0.35/bin/bootstrap.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.VMClassLoader.defineClass(libgcj.so.10)
at java.lang.ClassLoader.defineClass(libgcj.so.10)
at java.security.SecureClassLoader.defineClass(libgcj.so.10)
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.VMClassLoader.defineClass(libgcj.so.10)
at java.lang.ClassLoader.defineClass(libgcj.so.10)
at java.security.SecureClassLoader.defineClass(libgcj.so.10)
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.Class.forName(libgcj.so.10)
at java.lang.Class.initializeClass(libgcj.so.10)
...11 more
Solution 1:
It looks like you are not running the Sun JRE but GCJ, the GNU Java compiler, based on the "libgcj.so" present at the end of the stack trace lines. It is most likely a problem with either the JAVA_HOME, the JRE_HOME or the PATH variable.
Solution 2:
I have had same problem. In my case I was migrating from tomcat6 -> tomcat7 and I left my application configured in same way from tomcat6 and just try to start it in tomcat7. But in tomcat7 default server.xml
configuration there is not server lifecycle listener used (<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
). Consider reconfiguration of application that you want to migrate for tomcat7 (preffered way I think). Or just remove server lifecycle listener from server.xml
in this case.