2014-03-24 108 views
1

我在運行我的struts應用程序時遇到了這個問題。這,就是我web.xml文件過濾器類和名稱,服務器響應說是無法加載類在Struts2中啓動過濾器異常

<?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 

回答

0

struts2-gxp-plugin-2.3.16.1.jar/WEB-INF/lib刪除未使用的插件。在Struts 2.3.16.1中也不推薦使用org.apache.struts2.dispatcher.FilterDispatcher。請參閱Simple Example爲Struts2框架配置web.xml,方法是添加filterfilter-mapping標籤。

3

我用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-core-2.3.20.jar「

+1

這確實是我的問題。 我只是遵循教程中給出的struts2教程來得到這個問題 http://www.tutorialspoint.com/struts_2/struts2_tutorial.pdf –

0

上述答案的更多詳細信息:假設您正在使用eclipse,僅從.../WEB-INF/lib目錄中刪除無關文件是不夠的。如果您對項目進行了更改,eclipse將重新部署原始庫(jar文件)。要在eclipse中將它們從構建路徑中移除,以便它們不會被重新部署,請轉到Window >>首選項>> Java >>構建路徑>>用戶庫,並突出顯示並刪除不需要的jar。 (如果適用,當然也可以從WEB-INF/lib中刪除)。

相關問題