当尝试从 SWT 应用程序中启动嵌入式 tomcat Web 应用程序时,我收到错误(下面的堆栈跟踪):
java.lang.ClassCastException:org.apache.struts.action.ActionServlet 和java.lang.ClassCastException:org.apache.jasper.servlet.JspServlet
我已经搜索了/lib/目录和/WEB-INF/lib目录中的所有 jar,并且没有找到对任何 Servlet 类的任何重复引用。
该应用程序使用的是 Tomcat 6.0.36 和 Struts 1.3.10
应用程序源代码构建和编译成功,没有错误。
<项目>\lib 中的 Jar 文件
lib\annotations-api.jar
lib\axis\axis-ant.jar
lib\axis\axis.jar
lib\axis\commons-discovery-0.2.jar
lib\axis\jaxrpc.jar
lib\axis\junit.jar
lib\axis\saaj.jar
lib\axis\wsdl4j-1.5.1.jar
lib\catalina.jar
lib\com.dom.jsso.common-server.jar
lib\commons-dbcp-1.2.1.jar
lib\commons-logging-1.1.jar
lib\commons-pool.jar
lib\derby.jar
lib\derbytools.jar
lib\dom4j.jar
lib\ehcache-1.1.jar
lib\el-api.jar
lib\hibernate3.jar
lib\jasper.jar
lib\jsp-api.jar
lib\jta.jar
lib\odmg.jar
lib\org.springframework.asm-3.1.3.RELEASE.jar
lib\org.springframework.beans-3.1.3.RELEASE.jar
lib\org.springframework.context-3.1.3.RELEASE.jar
lib\org.springframework.core-3.1.3.RELEASE.jar
lib\org.springframework.web-3.1.3.RELEASE.jar
lib\org.springframework.web.struts-3.1.3.RELEASE.jar
lib\servlet-api.jar
lib\tomcat-coyote.jar
lib\tomcat-dbcp.jar
lib\tomcat-juli.jar
lib\tools\ojdbc14.jar
项目中使用的其他 jars(用于 JFace 和 SWT)
eclipse\plugins\org.eclipse.jface_3.7.0.v20110928-1505.jar
eclipse\plugins\org.eclipse.jface.text_3.7.2.v20111213-1208.jar
eclipse\plugins\org.eclipse.swt_3.7.2.v3740f.jar
eclipse\plugins\org.eclipse.swt.win32.win32.x86_3.7.2.v3740f.jar
tomcat\webapps\<project>\WEB-INF\lib 中的 Jar 文件
WEB-INF\lib\antlr-2.7.2.jar
WEB-INF\lib\commons-beanutils-1.8.0.jar
WEB-INF\lib\commons-digester-1.8.jar
WEB-INF\lib\commons-fileupload-1.1.1.jar
WEB-INF\lib\commons-validator-1.3.1.jar
WEB-INF\lib\oro-2.0.8.jar
WEB-INF\lib\struts-core-1.3.10.jar
WEB-INF\lib\struts-taglib-1.3.10.jar
tomcat/conf/web.xml 的 servlet 部分
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
web.xml 的 servlet 部分
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-config-adm.xml,/WEB-INF/struts-config-ajax.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
错误堆栈跟踪:
Dec 7, 2012 1:46:08 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from file [C:\projects\JSSO\com\example\conf\config.xml]
Dec 7, 2012 1:46:08 PM com.example.tomcat.embeddedTomcat init
INFO: Starting the tomcat bean
Dec 7, 2012 1:46:09 PM org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
Dec 7, 2012 1:46:09 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
Dec 7, 2012 1:46:10 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet action as unavailable
Dec 7, 2012 1:46:10 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet / threw load() exception
java.lang.ClassCastException: org.apache.struts.action.ActionServlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
at com.example.tomcat.embeddedTomcat.init(embeddedTomcat.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at com.example.util.ServiceLocator.getModuleManager(ServiceLocator.java:26)
at com.example.SWTMain$2.run(SWTMain.java:136)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at com.example.SWTMain.waitUntilExit(SWTMain.java:283)
at com.example.SWTMain.main(SWTMain.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.example.Main.invokeLoader(Main.java:138)
at com.example.Main.main(Main.java:123)
Dec 7, 2012 1:46:10 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet jsp as unavailable
Dec 7, 2012 1:46:10 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet / threw load() exception
java.lang.ClassCastException: org.apache.jasper.servlet.JspServlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
at com.example.tomcat.embeddedTomcat.init(embeddedTomcat.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at com.example.util.ServiceLocator.getModuleManager(ServiceLocator.java:26)
at com.example.SWTMain$2.run(SWTMain.java:136)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at com.example.SWTMain.waitUntilExit(SWTMain.java:283)
at com.example.SWTMain.main(SWTMain.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.example.Main.invokeLoader(Main.java:138)
at com.example.Main.main(Main.java:123)
Dec 7, 2012 1:46:10 PM org.apache.tomcat.util.modeler.Registry registerComponent
SEVERE: Null component null:type=JspMonitor,name=jsp,WebModule=//localhost/,J2EEApplication=none,J2EEServer=none
Dec 7, 2012 1:46:10 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8043
Dec 7, 2012 1:46:10 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8043
Dec 7, 2012 1:46:10 PM com.example.tomcat.embeddedTomcat init
INFO: Tomcat Started
Dec 7, 2012 1:46:11 PM org.apache.catalina.core.ApplicationDispatcher invoke
WARNING: Servlet jsp is currently unavailable
Dec 7, 2012 1:46:12 PM com.example.SWTMain$1 shellClosed
INFO: Closing the application
Dec 7, 2012 1:46:12 PM com.example.tomcat.embeddedTomcat shutdown
INFO: Shutting down tomcat
Dec 7, 2012 1:46:12 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8043