例一:
以下是Tomcat部署时报错提示
严重:
Exception starting filter struts2
Unable to load configuration. -
[unknown location]
at
org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
at
org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
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.
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4855)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5549)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1263)
at
org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1948)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at
java.util.concurrent.FutureTask.run(FutureTask.java:262)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
java.lang.Thread.run(Thread.java:745)
Caused by: Unable to load
configuration. - [unknown location]
at
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at
org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
at
org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
...
18 more
Caused by: Cannot locate the chosen
ObjectFactory implementation: spring - [unknown location]
at
org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:293)
at
org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:264)
at
org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:202)
at
com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)
at
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
...
20 more
解决方案:
也是网上下载的SSH例子在MyEclipse10上练习,但总是不能成功运行,看过该例子的帮助文档后知道原因是缺少struts2-spring-plugin-2.0.14
jar包了,把这个jar包找到粘贴到你的项目下WEB-INF中lib文件夹中,重新部署,启动,OK。
1. 自己郁闷的是要不是看作者的帮助文档都不知道是去烧这个文件;
2. 为何会缺少这个包?他是属于Spring还是Struts框架的一部分?怎么没有自动添加进去?是我在添加SSH框架时忘了勾选那个选项的原因吗?
3. SSH三个框架的结合那些包是必不可缺少的?也就是说那些包是用来三者之间通讯的?这个必须搞清楚,要不然后面再用SSH做项目时还会出错的。
4. 以上为自己练习时遇到的问题,下面的例二是网上收集的,希望自己有所帮助。
例二:
严重:
Exception starting filter struts2 方案总结
以下是Tomcat部署时报错提示
严重:
Exception starting filter struts2
Caught exception while loading file struts-default.xml - [unknown location]
at
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:839)
at
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:131)
at
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:100)
at
com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:130)
at
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
……
……
解决方案
1.是因为Hibernate和struts2引入的包产生冲突啦,去把xerces.jar移除就ok啦。路径所在
D:\ProgramFiles\MyEclipse 7.0M1\eclipse\dropins\myeclipse\eclipse\plugins\com.genuitec.org.hibernate.eclipse_3.2.2.z69100_CR1\myeclipse-data\3.0\lib
2.如果用的是tomcat+hibernate的话就去把tomcat中webapp中的对应的项目删除在重新发布一下就解决啦
这两种方案屡试不爽,哈哈...
例三
求解 严重: Exception starting filter struts2
严重: Exception starting filter struts2
java.lang.ClassNotFoundException:
prg.apache.struts2.dispatcher.FilterDispatcher
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1666)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1511)
at
org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:406)
at
org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:388)
at
org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:117)
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:248)
at
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:368)
at
org.apache.catalina.core.ApplicationFilterConfig.
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4193)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4801)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:771)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:988)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:427)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:649)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at
java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
2010-12-1 13:10:06
org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
2010-12-1 13:10:06
org.apache.catalina.core.StandardContext startInternal
严重: Context [/struts2] startup failed due to previous errors
解决方案:
提问者采纳:
很明显的错误:java.lang.ClassNotFoundException:
FilterDispatcher
找不到FilterDispatcher这个类(FilterDispatcher分发器,是Struts2框架的核心Dispatcher,没有它,也就谈不起Struts2框架)
首先:看看有没有导入Struts2相应的jar包,是否齐全。最少要导入五个基本包:
commons-logging-api-1.1.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.12.jar
xwork-2.0.6.jar
如果该包含的jar包都引入了,再看,配置文件web.xml是否配置正确,
struts2使用的是Filter充当Control 需要配置web.xml如下:注意类名和包名不要写错
如果以上两步都没有问题,那估计就是环境问题了,在开发中,环境问题是麻烦的事,检查你用的部署服务器(Tomcat或weblogic等)、IDE的版本(eclipse或者myEclipse),以及Struts2的版本...
struts2项目中web.xml配置2.1与2.0的区别
具体的过滤器类变了,2.0配置是以上写法
2.1以后是这样配置
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
另外,也与你导入jar包的位置有关,建议最好放入工程WEB-INF下的lib目录里,有时不能识别
提问者评价:太感谢了 我检查到我的web.xml配置错误了 哈哈 修改了 能运行了
以下是补充回答:
你是不是struts2和spring整合呀
web.xml应该没配置好
org.springframework.web.context.ContextLoaderListener
/WEB-INF/classes/applicationContext.xml
下面是我练习的一个SSH中的web.xml
其中有一段是关于加载applicationContext.xml文件路径的,主要是学习该文件在不同路径下的加载方法,例如例子的applicationContext.xml是在ssh\src目录下面的,我的是在ssh4\WebRoot\WEB-INF目录下的,所以就将原来的
更改为:
注意假设有多个*.xml文件需要说明加载路径,秩序加个逗号(,)接着增加即可,如下: