问题描述
我在web.xml里加以下filter后出现异常,怎么解决?jar包全加上了,struts.xml在classes里.<filter><filter-name>struts2x</filter-name><filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter><filter-mapping><filter-name>struts2x</filter-name><url-pattern>/*</url-pattern></filter-mapping>严重:Exceptionstartingfilterstruts2xUnabletoloadbean:type:class:com.opensymphony.xwork2.ObjectFactory-bean-jar:file:/C:/Program%20Files/Tomcat/Tomcat%206.0/webapps/struts2x/WEB-INF/lib/struts2-core-2.0.14.jar!/struts-default.xml:30:72atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208)atorg.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)atcom.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:131)atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)atorg.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)atorg.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)atorg.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:205)atorg.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)atorg.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)atorg.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)atorg.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4356)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)atorg.apache.catalina.core.StandardHost.start(StandardHost.java:719)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)atorg.apache.catalina.core.StandardService.start(StandardService.java:516)atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)atorg.apache.catalina.startup.Catalina.start(Catalina.java:578)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:585)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)Causedby:Beantypeclasscom.opensymphony.xwork2.ObjectFactorywiththenamexworkhasalreadybeenloadedbybean-file:/C:/Program%20Files/Tomcat/Tomcat%206.0/webapps/struts2x/WEB-INF/classes/struts-default.xml:30:72-bean-jar:file:/C:/Program%20Files/Tomcat/Tomcat%206.0/webapps/struts2x/WEB-INF/lib/struts2-core-2.0.14.jar!/struts-default.xml:30:72atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)...33more
解决方案
解决方案二:
你架包有问题,你去下最新架包用一下6个就没问题啦ognl-2.6.11.jarstruts2-core-2.1.6.jarxwork-2.1.2.jarcommons-fileupload-1.2.1.jarcommons-logging-1.0.4.jarfreemarker-2.3.13.jar
解决方案三:
Unabletoloadbean:type:class:com.opensymphony.xwork2.ObjectFactorystruts2默认使用spring的objectfactory.如果你把所有的jar都加上的话....它会以为你要使用webwork的objectfactory?引用1楼liuxining的回复:
你架包有问题,你去下最新架包用一下6个就没问题啦ognl-2.6.11.jarstruts2-core-2.1.6.jarxwork-2.1.2.jarcommons-fileupload-1.2.1.jarcommons-logging-1.0.4.jarfreemarker-2.3.13.jar
commons-fileupload-1.2.1.jar不是必须的吧.
解决方案四:
有谁出现过和我一样的错误,1楼,2楼的都试了还是同样的问题,我之前是只把struts2开头的都去掉,只留struts2-core-2.1.6.jar然后没出现错误.现在那样也不行.我把struts.xml放在classes里,每次刷新lib它怎么自动消失啊?我用的是struts2.1.6.请教还有其他方法吗?