使用struts 2.3 jar时,调度程序初始化失败

时间:2012-06-10 09:09:09

标签: java-ee struts2

我正在尝试使用struts2.3 jar的简单struts2应用程序但是它给出了一个调度程序初始化错误

2.3包括的罐子是:

commons-beanutils-1.7.0.jar
commons-chain-1.2.jar
commons-collections-3.1.jar
commons-digester-2.0.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
commons-validator-1.3.1.jar
freemarker-2.3.18.jar
ognl-3.0.4.jar
struts2-core-2.3.1.2.jar
xwork-core-2.3.1.2.jar

web.xml是

 <filter>
  <filter-name>struts2</filter-name>
  <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>

  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>

struts.xml是:

<struts>

<constant name="struts.devMode" value="true" />

<package name="/abc"  extends="struts-default">

<!-- action declarations.... -->
<action name="login" class="actions.TestLogin">
<result name="success">/WEB-INF/results/success.jsp</result>
<result name="error">/WEB-INF/results/error.jsp</result>
</action>

</package>
</struts>

异常堆栈是:

SEVERE: Dispatcher initialization failed
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:295)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
    at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
    at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
    at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:252)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    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.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    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:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.reflect.InvocationTargetException
    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:597)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    ... 33 more
Caused by: java.lang.ExceptionInInitializerError
    at com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlValueStackFactory.java:85)
    ... 38 more
Caused by: java.lang.IllegalArgumentException: Javassist library is missing in classpath! Please add missed dependency!
    at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:168)
    ... 39 more
Caused by: java.lang.ClassNotFoundException: javassist.ClassPool
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:165)
    ... 39 more
11 Jun, 2012 9:14:47 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter Struts2
java.lang.reflect.InvocationTargetException - Class: com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector
File: ContainerImpl.java
Method: inject
Line: 295 - com/opensymphony/xwork2/inject/ContainerImpl.java:295:-1
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:449)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    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.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    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:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:295)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
    at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
    at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
    at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:252)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)
    ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
    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:597)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    ... 33 more
Caused by: java.lang.ExceptionInInitializerError
    at com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlValueStackFactory.java:85)
    ... 38 more
Caused by: java.lang.IllegalArgumentException: Javassist library is missing in classpath! Please add missed dependency!
    at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:168)
    ... 39 more
Caused by: java.lang.ClassNotFoundException: javassist.ClassPool
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:165)
    ... 39 more
11 Jun, 2012 9:14:47 PM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
11 Jun, 2012 9:14:47 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Pr_StrutsLoginMap] startup failed due to previous errors
11 Jun, 2012 9:14:47 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/Pr_StrutsLoginMap] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@2d13981b]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@61672bbb]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
11 Jun, 2012 9:14:47 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
11 Jun, 2012 9:14:47 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
11 Jun, 2012 9:14:47 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
11 Jun, 2012 9:14:47 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4032 ms

我尝试使用struts 2.0 jar执行相同的应用程序 web.xml为

<filter>
  <filter-name>struts2</filter-name>
  <filter-class> org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>

  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>

这是工作文件但是有struts 2.3 jars它给出了一个例外 我无法弄清楚问题是什么。请指出可能存在的问题

谢谢你

4 个答案:

答案 0 :(得分:1)

在你的lib中维护以下版本的jar。我想你不会遇到任何问题

antlr-2.7.6.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-digester.jar
commons-fileupload-1.2.2.jar
commons-io-2.4.jar
commons-lang-1.2.jar
commons-logging-1.1.jar
freemarker-2.3.16.jar
javassist-3.7.ga.jar
ognl-3.0.jar
struts2-core-2.2.3.jar
xwork-core-2.2.1.jar

答案 1 :(得分:1)

Buddy您的错误堆栈跟踪本身会告诉您问题所在,请参阅堆栈跟踪中的这一行:

Caused by: java.lang.IllegalArgumentException: Javassist library is missing in classpath! Please add missed dependency!
at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:168)

这意味着缺少javassist-3.11.0.GA.jar(或类似的东西)文件。添加该文件,尝试再次运行您的应用程序,然后查看它给出的其他错误。最好的运气:)

答案 2 :(得分:0)

当某个罐子丢失时,会出现此错误。所以 我用你提供的jar测试了struts简单的应用程序 与你定义的问题相同 但是在包括这4个必要的罐子之后

commons-lang3-3.1.jar
javaassist-3.11.0.GA.jar
asm-3.3.jar
asm-commons-3.3.jar

问题已解决。

答案 3 :(得分:0)

试试这个:

<filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>