我们将 java 版本从 openjdk jre 1.7 切换到 sun jre 1.7,现在启动 tomcat 会出现以下错误:
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
我有同样的问题。在我的例子中,我是从 tomcat6 -> tomcat7 迁移的,我让我的应用程序以与 tomcat6 相同的方式配置,然后尝试在 tomcat7 中启动它。但是在 tomcat7 默认
server.xml
配置中没有使用服务器生命周期监听器(<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
)。考虑重新配置要为 tomcat7 迁移的应用程序(我认为是首选方式)。server.xml
或者在这种情况下只是删除服务器生命周期侦听器。看起来您运行的不是 Sun JRE,而是 GCJ,即 GNU Java 编译器,它基于堆栈跟踪行末尾的“libgcj.so”。这很可能是 JAVA_HOME、JRE_HOME 或 PATH 变量的问题。