struts2下的“Exception starting filter struts2”错误的问题

最近开始学习struts2,配置好了运行的时候总是有如下的错误:

严重: Exception starting filter struts2
java.lang.NoClassDefFoundError: Lorg/codehaus/plexus/PlexusContainer;
 at java.lang.Class.getDeclaredFields0(Native Method)
 at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
 at java.lang.Class.getDeclaredFields(Class.java:1743)
 at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:102)
 at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:84)
 at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:82)
 at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:155)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:81)
 at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:121)
 at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:329)
 at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:299)
 at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:298)
 at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:155)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:81)
 at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:121)
 at com.opensymphony.xwork2.inject.ContainerImpl.getConstructor(ContainerImpl.java:562)
 at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:460)
 at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:501)
 at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:549)
 at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:499)
 at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
 at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:134)
 at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:49)
 at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:431)
 at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:446)
 at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:48)
 at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:288)
 at com.opensymphony.xwork2.inject.ContainerImpl$2.call(ContainerImpl.java:117)
 at com.opensymphony.xwork2.inject.ContainerImpl$2.call(ContainerImpl.java:115)
 at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:542)
 at com.opensymphony.xwork2.inject.ContainerImpl.injectStatics(ContainerImpl.java:114)
 at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:494)
 at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:145)
 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
 at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
 at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
 at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
 at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
 at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:448)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
 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:295)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2008-4-9 13:31:49 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-4-9 13:31:49 org.apache.catalina.core.StandardContext start
严重: Context [/HelloWorld] startup failed due to previous errors
2008-4-9 13:31:50 org.apache.coyote.http11.Http11BaseProtocol start

主要就是web.xml中的过滤器的问题,web.xml的内容如下:

<? xml version="1.0" encoding="UTF-8" ?>
< web-app  id ="WebApp_ID"  version ="2.4"  xmlns ="http://java.sun.com/xml/ns/j2ee"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
    
< display-name >
    HelloWorld
</ 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 >
    
< welcome-file-list >
        
< welcome-file > index.html </ welcome-file >
    
</ welcome-file-list >
</ web-app >

出了问题就要解决啊,反复的查找了很多的资料,都没有详细说明怎么解决这个问题的,我一度都想把我的struts换成一个低版本的。偶然的一次尝试,我发现正常的lib目录下的jar文件比我的少了很多,我为了图方便是把struts下所有的jar文件都拷进了我的工程里,是不是这里出问题了呢?经过反复的尝试,终于找到了解决方案,确实是这里出了问题。罪魁祸首就是struts2-plexus-plugin-2.0.11.jar,struts-sitegraph-plugin-2.0.11.jar和struts2-spring-plugin-2.0.11.jar这三个文件,把他们从项目里删除后,就一切OK了!

但具体为什么这三个文件造成这样的错误,现在还不清楚,以后再慢慢了解了。

我的开发环境是eclipse 3.3+struts2.0.11+tomcat5.5+jdk1.6

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页