首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Struts2的helloword程序,该怎么处理

2013-09-11 
Struts2的helloword程序严重: Dispatcher initialization failedUnable to load configuration. - bean -

Struts2的helloword程序

严重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/D:/tomcat/webapps/Struts2Demo/WEB-INF/lib/struts2-core-2.3.4.jar!/struts-default.xml:51:178
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/D:/tomcat/webapps/Struts2Demo/WEB-INF/lib/struts2-core-2.3.4.jar!/struts-default.xml:51:178
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:243)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:210)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 31 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:233)
... 34 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 38 more
2012-7-12 20:37:26 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/D:/tomcat/webapps/Struts2Demo/WEB-INF/lib/struts2-core-2.3.4.jar!/struts-default.xml:51:178
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:450)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
Caused by: Unable to load configuration. - bean - jar:file:/D:/tomcat/webapps/Struts2Demo/WEB-INF/lib/struts2-core-2.3.4.jar!/struts-default.xml:51:178
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)
... 29 more
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/D:/tomcat/webapps/Struts2Demo/WEB-INF/lib/struts2-core-2.3.4.jar!/struts-default.xml:51:178
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:243)


at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:210)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
... 31 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:233)
... 34 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 38 more
2012-7-12 20:37:26 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2012-7-12 20:37:26 org.apache.catalina.core.StandardContext start
严重: Context [/Struts2Demo] startup failed due to previous errors
我刚开始接触Struts2,写了一个helloworld程序部署完后运行报上面的错误,向各位请教。

Java code
文件Struts.xml<?xml version="1.0" encoding="UTF-8" ?>  <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">  <struts>        <constant name="struts.devMode" value="true" />        <package name="hello" extends="struts-default" namespace="/">           <action name="hello" class="core.HelloWorldAction">              <result>/HelloWorld.jsp</result>           </action>        </package>       </struts>文件web.xml<?xml version="1.0" encoding="UTF-8"?>   <web-app version="2.5"   xmlns="http://java.sun.com/xml/ns/javaee"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">       <filter>          <filter-name>              struts2           </filter-name>           <filter-class>               org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter           </filter-class>       </filter>           <filter-mapping>           <filter-name>struts2</filter-name>           <url-pattern>/*</url-pattern>       </filter-mapping>           <welcome-file-list>           <welcome-file>index.jsp</welcome-file>       </welcome-file-list>   </web-app>文件Helloworld.javaimport com.opensymphony.xwork2.ActionSupport;public class HelloWorld extends ActionSupport {    private static final long serialVersionUID = 1L;    private String name = null;        public void setName(String name){        this.name = name;    }    public String getName(){        return name;    }    @Override    public String execute() throws Exception {        // TODO Auto-generated method stub        name="java菜鸟";        return SUCCESS;    }    }


[解决办法]
java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException
没看这个提示哦?fileupload.jar没有加,我估计你还会报java.lang.ClassNotFoundException
根据提示加上去就行了

热点排行