struts2.0jar包导入Unable to load configuration. - bean问题原因及解决方案

导入下面五个jar包后,

commons-logging-1.0.4.jar

 

freemarker-2.3.12.jar

 

log4j-1.2.14.jar

 

ognl-2.6.11.jar

 

struts2-core-2.1.2.jar

 

xwork-2.1.1.jar

显示如下错误

2011-5-1 21:59:06 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/D:/Program%20Files/Java/tools/apache-tomcat-6.0.16/webapps/StrutsTest/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:213)
    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: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/D:/Program%20Files/Java/tools/apache-tomcat-6.0.16/webapps/StrutsTest/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:239)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:100)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:156)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    ... 30 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getDeclaredConstructors(Class.java:1836)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229)
    ... 33 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 37 more
2011-5-1 21:59:06 org.apache.catalina.core.StandardContext start
严重: Error filterStart

 

解决办法导入commons-fileupload-1.2.1.jar

原因

查看StrutsTest/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:46:178得知:

<bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="struts" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="default"/>

又由于错误信息

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException

Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException

综上可知:缺少jar包commons-fileupload-1.2.1.jar

 

一般情况下struts工程报Unable to load configuration. - bean - jar:错误,都是缺少相应jar导致

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值