spring与struts2整合出现常见错误
错误信息
严重: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/F:/Struts2/Struts2/WebRoot/WEB-
INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178
解决办法
少jar包,添加
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
错误信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'sessionFactory' defined in ServletContext resource [/WEB-
INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit
(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
解决办法:
Spring中的asm-xxx.jar 和 Hibernate中的 asm.jar 冲突,移除 spring aop 中的 asm-xxx.jar 或者
出现 action 为null 时移除 spring aop
错误信息
Exception starting filter struts2
Cannot locate the chosen ObjectFactory implementation: The
com.opensymphony.xwork2.ObjectFactory implementation class - [unknown location]
解决办法:
少jar包,添加struts2-spring-plugin-2.0.14.jar
struts.xml中,加上一句话
<constant name="struts.objectFactory" value="spring"/>
错误信息
严重: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/F:/Struts2/Struts2/WebRoot/WEB-
INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178
解决办法
少jar包,添加
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
错误信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'sessionFactory' defined in ServletContext resource [/WEB-
INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit
(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
解决办法:
Spring中的asm-xxx.jar 和 Hibernate中的 asm.jar 冲突,移除 spring aop 中的 asm-xxx.jar 或者
出现 action 为null 时移除 spring aop
错误信息
Exception starting filter struts2
Cannot locate the chosen ObjectFactory implementation: The
com.opensymphony.xwork2.ObjectFactory implementation class - [unknown location]
解决办法:
少jar包,添加struts2-spring-plugin-2.0.14.jar
struts.xml中,加上一句话
<constant name="struts.objectFactory" value="spring"/>
错误信息
严重: Exception starting filter struts2
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
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:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: Caught exception while loading file struts-default.xml - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:894)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:144)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:164)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 30 more
Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.<init>(SAX2DOM.java:69)
at com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory.getSerializationHandler(TransletOutputHandlerFactory.java:187)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:392)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:137)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.setup(DomHelper.java:205)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:190)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:181)
at com.opensymphony.xwork2.util.DomHelper$DOMBuilder.<init>(DomHelper.java:167)
at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:107)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:885)
... 34 more
经过在网上查找原因,说是xerces-2.6.2.jar与hibernate3.jar里面出现冲突,于是删除xerces-2.6.2.jar再重新启动tomcat6问题解决,程序正常运行
我的异常网推荐解决方案:org.springframework.beans.factory.BeanCreationException:,http://www.myexception.cn/j2ee/10759.html