今天,在啟動Tomcat服務器的時候,突然發現不能load已經存在的Servlet類。
提示java.lang.UnsupportedClassVersionError: Bad version number in .class file ,JDK版本號不支持問題,拋出異常,詳細異常信息如下所示:
2009-8-3 12:35:54 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.16.
2009-8-3 12:35:54 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2009-8-3 12:35:55 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2009-8-3 12:35:55 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2009-8-3 12:35:55 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 949 ms
2009-8-3 12:35:55 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-8-3 12:35:55 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.20
2009-8-3 12:35:56 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2009-8-3 12:35:56 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2009-8-3 12:35:56 org.apache.tomcat.util.modeler.Registry registerComponent
嚴重: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/filter,J2EEApplication=none,J2EEServer=none
2009-8-3 12:35:56 org.apache.catalina.startup.HostConfig deployDirectory
嚴重: Error deploying web application directory filter
java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class org.shirdrn.action.FilterAction)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1854)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:890)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1354)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:108)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:58)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1068)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4339)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-8-3 12:35:56 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2009-8-3 12:35:56 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2009-8-3 12:35:56 org.apache.catalina.startup.Catalina start
信息: Server startup in 1318 ms
因為原來一直是在MyEclipse 6.5上開發,昨天我重新安裝了MyEclipse 7.1,在MyEclipse 7.1上。我猜想可能是MyEclipse 7.1版本比較新的原因,但是版本新導致不能加載Servlet這種可能不是很大,如果連加載類都成問題,那可不是一款優秀的IDE,起初我還是試著按照這種猜測去嘗試,將在MyEclipse 6.5下最原始的備份重新導入MyEclipse 7.1,結果問題依然。