过滤器 struts2 无法初始化

Filter struts2 could not be initialized

我最初想将一个 JAVA EE 项目迁移到 maven 中。但是,我 运行 进入调度错误。 我在文件中得到了这个堆栈跟踪: C:\Program Files 使用(x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\My_SERVER\SystemOut.log

> [22/03/18 07:46:32:755 VET] 00000020 XmlConfigurat I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Parsing configuration file [struts-default.xml] [22/03/18 07:46:32:766
> VET] 00000020 XmlConfigurat I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Parsing configuration file [struts-plugin.xml] [22/03/18 07:46:32:812
> VET] 00000020 XmlConfigurat I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Parsing configuration file [struts.xml] [22/03/18 07:46:32:814 VET]
> 00000020 DefaultConfig I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Overriding property struts.i18n.reload - old value: false new value:
> true [22/03/18 07:46:32:814 VET] 00000020 DefaultConfig I
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
> Overriding property struts.configuration.xml.reload - old value: false
> new value: true [22/03/18 07:46:32:858 VET] 00000020 Dispatcher    E
> com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
> 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.create(ContainerBuilder.java:207)
>   at com.opensymphony.xwork2.inject.Scope.create(Scope.java:51)   at
> com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:93)
>   at
> com.opensymphony.xwork2.inject.ContainerBuilder.call(ContainerBuilder.java:487)
>   at
> com.opensymphony.xwork2.inject.ContainerBuilder.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:371)   at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
>   at
> org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
>   at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:140)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:509)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:423)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:282)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:340)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:812)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:917)
>   at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:924)
>   at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:852)
>   at
> com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3610)
>   at
> com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:274)
>   at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:926)
>   at
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
>   at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
>   at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
>   at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
>   at
> com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
>   at
> com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1772)
>   at
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
>   at
> com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
>   at
> com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
>   at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)     at
> com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)   at
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
>   at com.ibm.io.async.ResultHandler.run(ResultHandler.java:896)     at
> com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527) Caused by:
> java.lang.reflect.InvocationTargetException   at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>   at java.lang.reflect.Method.invoke(Method.java:599)     at
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
>   ... 40 more Caused by: java.lang.NoClassDefFoundError:
> ognl.OgnlRuntime (initialization failure)     at
> java.lang.J9VMInternals.initialize(J9VMInternals.java:140)    at
> com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlValueStackFactory.java:85)
>   ... 45 more
> 
> [22/03/18 07:46:32:860 VET] 00000020 webapp        E
> com.ibm.ws.webcontainer.webapp.WebApp logError SRVE0293E: [Erreur du
> servlet]-[ognl.OgnlRuntime (initialization failure)] :
> 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:428)    at
> org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
>   at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:140)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:509)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:423)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:282)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:340)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:812)
>   at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:917)
>   at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:924)
>   at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:852)
>   at
> com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3610)
>   at
> com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:274)
>   at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:926)
>   at
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
>   at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
>   at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
>   at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
>   at
> com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
>   at
> com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1772)
>   at
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
>   at
> com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
>   at
> com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
>   at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)     at
> com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)   at
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
>   at com.ibm.io.async.ResultHandler.run(ResultHandler.java:896)     at
> com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527) 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.create(ContainerBuilder.java:207)
>   at com.opensymphony.xwork2.inject.Scope.create(Scope.java:51)   at
> com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:93)
>   at
> com.opensymphony.xwork2.inject.ContainerBuilder.call(ContainerBuilder.java:487)
>   at
> com.opensymphony.xwork2.inject.ContainerBuilder.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:371)   at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
>   ... 27 more Caused by: java.lang.reflect.InvocationTargetException
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>   at java.lang.reflect.Method.invoke(Method.java:599)     at
> com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
>   ... 40 more Caused by: java.lang.NoClassDefFoundError:
> ognl.OgnlRuntime (initialization failure)     at
> java.lang.J9VMInternals.initialize(J9VMInternals.java:140)    at
> com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlValueStackFactory.java:85)
>   ... 45 more
> 
> [22/03/18 07:46:32:873 VET] 00000020 srt           W
> com.ibm.ws.webcontainer.srt.SRTServletResponse addHeader WARNING:
> Cannot set header. Response already committed. [22/03/18 07:46:32:874
> VET] 00000020 srt           W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader WARNING:
> Cannot set header. Response already committed. [22/03/18 07:46:32:875
> VET] 00000020 srt           W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader WARNING:
> Cannot set header. Response already committed. [22/03/18 07:46:32:875
> VET] 00000020 srt           W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setDateHeader WARNING:
> Cannot set header. Response already committed.

我将此依赖项添加到我的 POM.xml(我认为它丢失了)

<dependency>
    <groupId>org.apache.struts.xwork</groupId>
    <artifactId>xwork-core</artifactId>
    <version>2.2.1</version>
</dependency>

但我仍然有错误。 谁能告诉我我错过了什么?可能是因为我使用的是 Eclipse NEON1?

我有 JDK1.7.0_71 和 Websphere 7.0.0.

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_71

MAVEN_HOME=D:\Maven\apache-maven-3.3.9
Caused by: java.lang.NoClassDefFoundError:
 ognl.OgnlRuntime (initialization failure)  at

您在 运行 时缺少对 class 路径的 OGNL 依赖项。

xwork-corestruts2-core 工件的传递依赖。

OGNL也是传递依赖

关于第二个错误:

Response has been already commuted.

Struts 试图通过在内部使用 servlet 响应来 return 错误结果,或者转发到错误页面,如果响应已被交换,则无法做到这一点。一旦缓冲区被刷新,响应就会被转换。您应该检查响应对象上缓冲区的大小以及写入了多少字节。

javassist 依赖很混乱。 我在 POM 文件中添加了这个依赖项:

<dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.12.1.GA</version> 
</dependency>

对我有用。