首页

基于tomcat启动项目失败,报“java.lang.Error: Unresolved compilation problems”异常

标签:Tomcat,ServletContextEvent,HttpSessionAttributeListener,HttpSessionListener,Unresolved     发布时间:2016-07-30   

一、异常描述

eclipse启动在tomcat启动web项目报error错误 - "Error configuring application listener of class...java.lang.Error: Unresolved compilation problems...重: Context [/xwood-pms] startup failed due to previous errors..“,具体异常内容如下

2016-7-30 17:23:09 org.apache.catalina.core.AprLifecycleListener init@b@信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:NJPFJavajdk1.6.0_39in;C:WindowsSunJavain;C:Windowssystem32;C:Windows;C:NJPFJavajdk1.6.0_39jrein;C:/NJ/PF/Java/jdk1.6.0_39/bin/../jre/bin/server;C:/NJ/PF/Java/jdk1.6.0_39/bin/../jre/bin;C:/NJ/PF/Java/jdk1.6.0_39/bin/../jre/lib/amd64;C:Program FilesGitin;C:Program Files@b@odejs;C:Program Files (x86)Common FilesNetSarang;C:NJSERVER	omcat6-batin;C:NJPFJavajdk1.6.0_39in;C:NJPForacleproduct.2.0db_1in;C:NJPFproduct	.2.0dbhome_2in;C:NJPFproduct	.2.0dbhome_1in;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShell1.0;C:NJPFTortoiseSVNin;C:Program Files@b@odejs;C:NJSSH Secure Shell;C:Users@b@ijunAppDataRoaming@b@pm;C:NJPForacleclient;C:NJPFeclipse-jee-juno-SR2-win32-x86_64eclipse;;.@b@2016-7-30 17:23:09 org.apache.coyote.http11.Http11Protocol init@b@信息: Initializing Coyote HTTP/1.1 on http-8080@b@2016-7-30 17:23:09 org.apache.coyote.http11.Http11Protocol init@b@信息: Initializing Coyote HTTP/1.1 on http-8443@b@2016-7-30 17:23:09 org.apache.catalina.startup.Catalina load@b@信息: Initialization processed in 1254 ms@b@2016-7-30 17:23:09 org.apache.catalina.core.StandardService start@b@信息: Starting service Catalina@b@2016-7-30 17:23:09 org.apache.catalina.core.StandardEngine start@b@信息: Starting Servlet Engine: Apache Tomcat/6.0.32@b@2016-7-30 17:23:11 org.apache.catalina.core.StandardContext listenerStart@b@严重: Error configuring application listener of class com.xwood.pms.util.GetInstanceByBeanName@b@java.lang.Error: Unresolved compilation problems: @b@    The import javax.servlet.ServletContextEvent cannot be resolved@b@    The import javax.servlet.ServletContextListener cannot be resolved@b@    The import javax.servlet.http.HttpSessionAttributeListener cannot be resolved@b@    The import javax.servlet.http.HttpSessionBindingEvent cannot be resolved@b@    The import javax.servlet.http.HttpSessionEvent cannot be resolved@b@    The import javax.servlet.http.HttpSessionListener cannot be resolved@b@    ServletContextListener cannot be resolved to a type@b@    HttpSessionListener cannot be resolved to a type@b@    HttpSessionAttributeListener cannot be resolved to a type@b@    ServletContextEvent cannot be resolved to a type@b@    HttpSessionEvent cannot be resolved to a type@b@    HttpSessionEvent cannot be resolved to a type@b@    HttpSessionBindingEvent cannot be resolved to a type@b@    HttpSessionBindingEvent cannot be resolved to a type@b@    HttpSessionBindingEvent cannot be resolved to a type@b@    ServletContextEvent cannot be resolved to a type@b@    at com.xwood.pms.util.GetInstanceByBeanName.<init>(GetInstanceByBeanName.java:3)@b@    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)@b@    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)@b@    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)@b@    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)@b@    at java.lang.Class.newInstance0(Class.java:357)@b@    at java.lang.Class.newInstance(Class.java:310)@b@    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4149)@b@    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)@b@    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)@b@    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)@b@    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)@b@    at org.apache.catalina.core.StandardService.start(StandardService.java:525)@b@    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)@b@    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)@b@    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)@b@    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)@b@    at java.lang.reflect.Method.invoke(Method.java:597)@b@    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)@b@    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)@b@2016-7-30 17:23:11 org.apache.catalina.core.StandardContext listenerStart@b@严重: Skipped installing application listeners due to previous error(s)@b@2016-7-30 17:23:11 org.apache.catalina.core.StandardContext start@b@严重: Error listenerStart@b@2016-7-30 17:23:11 org.apache.catalina.core.StandardContext start@b@严重: Context [/xwood-pms] startup failed due to previous errors@b@log4j:WARN No appenders could be found for logger (org.directwebremoting.util.Logger).@b@log4j:WARN Please initialize the log4j system properly.@b@2016-7-30 17:23:12 org.apache.catalina.startup.HostConfig deployDescriptor@b@信息: Deploying configuration descriptor host-manager.xml@b@2016-7-30 17:23:12 org.apache.catalina.startup.HostConfig deployDescriptor@b@信息: Deploying configuration descriptor manager.xml@b@2016-7-30 17:23:12 org.apache.catalina.startup.HostConfig deployDirectory@b@信息: Deploying web application directory docs@b@2016-7-30 17:23:12 org.apache.catalina.startup.HostConfig deployDirectory@b@信息: Deploying web application directory examples@b@2016-7-30 17:23:12 org.apache.catalina.core.ApplicationContext log@b@信息: ContextListener: contextInitialized()@b@2016-7-30 17:23:12 org.apache.catalina.core.ApplicationContext log@b@信息: SessionListener: contextInitialized()@b@2016-7-30 17:23:12 org.apache.catalina.startup.HostConfig deployDirectory@b@信息: Deploying web application directory ROOT@b@2016-7-30 17:23:12 org.apache.coyote.http11.Http11Protocol start@b@信息: Starting Coyote HTTP/1.1 on http-8080@b@2016-7-30 17:23:12 org.apache.coyote.http11.Http11Protocol start@b@信息: Starting Coyote HTTP/1.1 on http-8443@b@2016-7-30 17:23:12 org.apache.jk.common.ChannelSocket init@b@信息: JK: ajp13 listening on /0.0.0.0:8009@b@2016-7-30 17:23:12 org.apache.jk.server.JkMain start@b@信息: Jk running ID=0 time=0/35  config=null@b@2016-7-30 17:23:12 org.apache.catalina.startup.Catalina start@b@信息: Server startup in 3034 ms

二、解决步骤

1. 打开日志中异常类GetInstanceByBeanName,发现确实sevlet的容器包依赖,打开项目配置Libraries确实tomcat库包,如图所示

基于tomcat启动项目失败,报“java.lang.Error: Unresolved compilation problems”异常

2. 选择"Server Libray [tomcat6](unbound)",点击Remove按钮,如下图

基于tomcat启动项目失败,报“java.lang.Error: Unresolved compilation problems”异常

3. 删除之后,点击"Add Libray"按钮,再选择"Server Runtime"项,在点击"Next>"按钮,如下图

基于tomcat启动项目失败,报“java.lang.Error: Unresolved compilation problems”异常

4. 选择"Apache Tomcat v6.0",点击Finish按钮,如下图

基于tomcat启动项目失败,报“java.lang.Error: Unresolved compilation problems”异常

5. 如下图,正常加载依赖包,点击ok,项目启动正常

基于tomcat启动项目失败,报“java.lang.Error: Unresolved compilation problems”异常

<<热门下载>>