Struts2 WEB-INF/lib/struts2-core-2.1.8.1jar!/struts-default.xml:47:178

【转】Struts2 WEB-INF/lib/struts2-core-2.1.8.1jar!/struts-default.xml:47:178

由于目前好像还没有支持struts2的插件,所以就上网找了一些资料解决在myeclipse中配置struts2(了解到struts2必须要在jdk1.6和tomcat6.x)。于是就安装网上的许多版本开始配置,都说简单struts2小程序配置过程中只需导入的struts2的包有5个:struts2-core.jar,commons-logging.jar,freemarker.jar,ognl.jar,xwork.jar。安装实例配置好以后,开始运行,可是出现一下错误:

2010-4-1 23:29:41 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts
Unable to load configuration. - bean - jar:file:/D:/Program%20Files/tomcat-6.0.18/webapps/OA/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
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.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
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:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
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 configuration. - bean - jar:file:/D:/Program%20Files/tomcat-6.0.18/webapps/OA/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
... 28 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:/Program%20Files/tomcat-6.0.18/webapps/OA/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:221)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 30 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/RequestContext
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:211)
... 33 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 37 more
2010-4-1 23:29:41 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2010-4-1 23:29:41 org.apache.catalina.core.StandardContext start
严重: Context [/OA] startup failed due to previous errors
2010-4-1 23:29:41 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2010-4-1 23:29:41 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2010-4-1 23:29:41 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2010-4-1 23:29:41 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/32 config=null
2010-4-1 23:29:41 org.apache.catalina.startup.Catalina start
信息: Server startup in 2667 ms

开始时上网找了许多的资料,可一般都没有解决办法,或是给的方法没用,熬了我一两个小时,后来我自己仔细分析了下错误,发现错误中指明struts-default.xml:47:178,struts2-core.jar包中的struts-default文件的47行有问题,于是我打开struts-default.xml,47行为:



发现要加载org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest。查看这个类的源文件
其中前面有这样几句 :


package org.apache.struts2.dispatcher.multipart;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import org.apache.struts2.StrutsConstants;

import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;


public class JakartaMultiPartRequest implements MultiPartRequest {

//下面略
在这个类中必须引入org.apache.commons.fileupload.*;
而错误也许没有加载这个文件上传包所以找不到类 。

于是我就把commons-ileupload.jar 和 commons-io.jar 导入,结果错误解决了。


你可能感兴趣的:(Struts2,struts2,Exception)