随笔 - 117  文章 - 72  trackbacks - 0

声明:原创作品(标有[原]字样)转载时请注明出处,谢谢。

常用链接

常用设置
常用软件
常用命令
 

订阅

订阅

留言簿(7)

随笔分类(130)

随笔档案(123)

搜索

  •  

积分与排名

  • 积分 - 152573
  • 排名 - 390

最新评论

[标题]:[转]Struts2.1.6 - Unable to load configuration
[时间]:2009-7-7
[摘要]:Unable to load configuration. - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
[关键字]:struts、spring、configuration、struts-default、MVC、Apache,框架、SSH
[环境]:Struts2.1.6、JDK6、Tomcat6
[作者]:Winty (wintys@gmail.com) http://www.blogjava.net/wintys

[错误]:
    在Web Project中加入了以下5个Struts2核心jar:
    struts2-core-2.1.6.jar
    xwork-2.1.2.jar
    freemarker-2.3.13.jar
    ognl-2.6.11.jar
    commons-logging-1.0.4.jar
    启动Tomcat时,提示如下错误信息:

2009-7-7 19:55:12 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter MyStruts2
Unable to load configuration. - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
    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:3693)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)
    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:710)
    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:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: Unable to load bean: type:com.opensymphony.xwork2.UnknownHandler class:org.apache.struts2.convention.ConventionUnknownHandler - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    ... 30 more
Caused by: Bean type interface com.opensymphony.xwork2.UnknownHandler with the name default has already been loaded by bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-codebehind-plugin-2.1.6.jar!/struts-plugin.xml:29:122 - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:206)
    ... 33 more
2009-7-7 19:58:07 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter MyStruts2
Unable to load configuration. - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
    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:3693)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1307)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1571)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1580)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1560)
    at java.lang.Thread.run(Thread.java:619)
Caused by: Unable to load bean: type:com.opensymphony.xwork2.UnknownHandler class:org.apache.struts2.convention.ConventionUnknownHandler - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    ... 17 more
Caused by: Bean type interface com.opensymphony.xwork2.UnknownHandler with the name default has already been loaded by bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-codebehind-plugin-2.1.6.jar!/struts-plugin.xml:29:122 - bean - jar:file:/F:/Web/homesite/jsp/struts/WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml:30:119
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:206)
    ... 20 more

[原因&解决]:
     这是apache的失误。按照官方文档说明,运行Struts2必须加载5个核心jar包,也就是咱们一开始拷贝的5个jar包,如果你用的是 Struts2之前的版本是没有问题的,但是如果去下载这个新版本,就会报如上错误,因为还需要加载另外两个jar包,可是官方的说明文档没有更新。

    解决方案:在Struts2的解压缩文件夹内的lib文件夹里, 我们找到下列2个jar : commons-fileupload-1.2.1.jar、commons-io-1.3.2.jar,把他们复制到项目根目录下的"WEB-INF"lib"文件夹内。

    既然少了jar,图省事把包struts lib下的jar全都复制到工程目录中。这样做又会出现类似上面的错误提示。所以如非必要,不要加载其它的jar,这大概是struts2.1.6的bug。一般只需加载以下7个jar:
    struts2-core-2.1.6.jar、
    xwork-2.1.2.jar、
    freemarker-2.3.13.jar、
    ognl-2.6.11.jar、
    commons-logging-1.0.4.jar、
    commons-fileupload-1.2.1.jar、
    commons-io-1.3.2.jar

    还有"叶现一"(http://blog.csdn.net/yexianyi/)提供的办法:将struts-2.1.6-all.zip中apps文件夹中struts2-blank-2.1.6.war文件解压。进入struts2-blank-2.1.6"WEB-INF"lib,只将该文件夹下的9个jar包导入到项目工程中即可,其余的包如果没有用到切不可轻易导入

[参考资料]:
[1] 严重 exception starting filter struts2 unable to load configuration : http://blog.csdn.net/cocohufei/archive/2009/05/13/4176058.aspx
[2] struts2.1.6简单的实例加载struts-default.xml的问题 : http://topic.csdn.net/u/20090212/14/4648539f-e6c1-4a1b-94b9-944712affa96.html
[3] Struts2.x异常- Unable to load configuration..../WEB-INF/lib/struts2-convention-plugin-2.1.6.jar!/struts-plugin.xml : http://blog.csdn.net/yexianyi/archive/2009/02/18/3905836.aspx
[4] struts 2.1.6 "Unable to load configuration"异常 : http://blog.csdn.net/thirdprince/archive/2009/04/06/4052027.aspx

posted on 2009-07-07 23:16 天堂露珠 阅读(2085) 评论(1)  编辑  收藏 所属分类: ErrorStruts

FeedBack:
# re: [转]Struts2.1.6 - Unable to load configuration 2009-07-08 00:19 路过
非常感谢!!!  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: