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

严重:Exceptionstartingfilterstruts2

Unabletoloadconfiguration.-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

atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)

atorg.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)

atorg.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424)

atorg.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:213)

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:597)

atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Causedby:Unabletoloadbean:type:org.apache.struts2.dispatcher.multipart.MultiPartRequestclass: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

atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:239)

atorg.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:100)

atcom.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:156)

atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)

...30more

Causedby:java.lang.NoClassDefFoundError:org/apache/commons/fileupload/FileUploadException

atjava.lang.Class.getDeclaredConstructors0(NativeMethod)

atjava.lang.Class.privateGetDeclaredConstructors(Class.java:2389)

atjava.lang.Class.getDeclaredConstructors(Class.java:1836)

atcom.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229)

...33more

Causedby:java.lang.ClassNotFoundException:org.apache.commons.fileupload.FileUploadException

atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)

atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)

atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

...37more

2011-5-121:59:06org.apache.catalina.core.StandardContextstart

严重: 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导致

相关推荐