Struts2中的异常启动过滤器

时间:2014-03-24 17:40:08

标签: xml eclipse struts2

我在运行struts应用程序时遇到此问题。这是我的web.xml文件,其中包含过滤器类和名称,服务器响应说它无法加载类

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Struts2starter</display-name>
  <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>   
</web-app>

例外:

SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/C:/Users/My/newworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2starter/WEB-INF/lib/struts2-gxp-plugin-2.3.16.1.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer - bean - jar:file:/C:/Users/My/newworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2starter/WEB-INF/lib/struts2-gxp-plugin-2.3.16.1.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 16 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainer
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    ... 19 more

3 个答案:

答案 0 :(得分:4)

struts 2.3.20也遇到了同样的问题。我通过仅使用以下九个罐子去除所有不必要的罐子来解决它:

公地文件上传-1.3.1jar,
公地IO-2.2.jar,
公地lang3-3.2.jar,
共享记录-1.1.3.jar,
freemarker的-2.3.19.jar,
Javassist进行-3.11.0.GA.jar,
OGNL-3.0.6.jar,
Struts2的核心 - 2.3.20.jar,
XWork的核 - 2.3.20.jar&#34;

答案 1 :(得分:0)

struts2-gxp-plugin-2.3.16.1.jar删除/WEB-INF/lib中未使用过的插件。 Struts 2.3.16.1中也不推荐使用org.apache.struts2.dispatcher.FilterDispatcher。通过添加web.xmlfilter标记,查看为{2}配置Struts2框架的filter-mapping

答案 2 :(得分:0)

上述答案的更多细节:假设您使用的是eclipse,它还不足以从... / WEB-INF / lib目录中删除无关的文件。如果对项目进行更改,eclipse将重新部署原始库(jar文件)。要在eclipse中从构建路径中删除它们,以便它们不能重新部署,请转到Window&gt;&gt;偏好设置&gt;&gt; Java&gt;&gt;构建路径&gt;&gt;用户库,突出显示并删除不需要的jar。 (当然,如果适用,从WEB-INF / lib中删除。)