2

我正在尝试一个带有 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

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

<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

4 回答 4

1

在您的库中维护以下版本的 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
于 2013-02-26T13:42:08.243 回答
1

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

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(或类似的)文件。添加该文件,尝试再次运行您的应用程序,然后查看它给出的其他错误。祝你好运:)

于 2014-02-01T15:08:33.677 回答
0

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

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

问题解决了 。

于 2014-08-08T04:36:24.633 回答
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>
于 2015-09-21T15:53:02.767 回答