首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

lib中jar文件拷贝的不全引发的异常

2013-09-11 
lib中jar文件拷贝的不全引发的错误先把一些设定的贴上来:WEB-INF/web.xml:?xml version1.0 encoding

lib中jar文件拷贝的不全引发的错误

先把一些设定的贴上来:
WEB-INF/web.xml:

<?xml version="1.0" encoding="GBK"?>
<web-app 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"
   version="2.5">
    <!--定义struts 2的FileterDispatcher的Filter-->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>  
    <filter-mapping>
        <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
    </filter-mapping>     
      
        <welcome-file-list>
     <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
</web-app>

WEB-INF\classes\struts.xml:
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="johnson.action" extends="struts-default">
        <action name="Login" class="johnson.action.loginAction">
            <result name="error">/error.jsp</result>
            <result name="success">/welcome.jsp</result>      
        </action>     
    </package>
</struts>

loginAction.java:
package johnson.action;
public class loginAction{
    private String username;
    private String password;

    public String getUsername()
    {
        return username;
    }
    public void setUsername(String username)
    {
        this.username = username;
    }

    public String getPassword()
    {
        return password;
    }
    public void setPassword(String password)
    {
        this.password = password;
    }
    //处理用户请求
    public String execute() throws Exception{
         //账号,密码:scott/tiger时,返回success
         //否则返回error
         if(getUsername().equals("scott") && getPassword().equals("tiger"))
         {
                 return "success";
         }
         else
         {
                 return "error";
         }       
    }  
}

一开始,从struts2.2.1导入了5个包:
commons-logging-1.0.4.jar
freemarker-2.3.16.jar
ognl-3.0.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar

结果启动tomcat的时候,报错了:

2010-9-25 15:21:05 com.opensymphony.xwork2.util.logging.commons.CommonsLogger wa
rn
警告: Could not create JarEntryRevision for [jar:file:/D:/Java/apache-tomcat-6.0
.29/webapps/johnson/WEB-INF/lib/struts2-core-2.2.1.jar]!
java.lang.NoClassDefFoundError: org/apache/commons/io/output/NullOutputStream
        at com.opensymphony.xwork2.util.FileManager$JarEntryRevision.build(FileM
anager.java:307)
        at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:14
5)
        at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:10
5)
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loa
dConfigurationFiles(XmlConfigurationProvider.java:898)
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loa
dDocuments(XmlConfigurationProvider.java:154)
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.ini
t(XmlConfigurationProvider.java:121)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContai
ner(DefaultConfiguration.java:179)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
ConfigurationManager.java:66)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Di
spatcher.java:371)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
        at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.
java:190)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:295)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:422)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFi
lterConfig.java:115)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:4001)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
651)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1041)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:964)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:321)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:5
19)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.output.NullOu
tputStream
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1645)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1491)
        ... 38 more
2010-9-25 15:21:06 com.opensymphony.xwork2.util.logging.commons.CommonsLogger in
fo
信息: Parsing configuration file [struts-default.xml]
2010-9-25 15:21:06 com.opensymphony.xwork2.util.logging.commons.CommonsLogger er
ror
严重: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/D:/Java/apache-tomcat-6.0.29/we
bapps/johnson/WEB-INF/lib/struts2-core-2.2.1.jar!/struts-default.xml:48:178
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
ConfigurationManager.java:69)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Di
spatcher.java:371)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
        at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.
java:190)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:295)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:422)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFi
lterConfig.java:115)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:4001)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
651)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1041)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:964)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:321)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:5
19)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.Mul
tiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequ
est - bean - jar:file:/D:/Java/apache-tomcat-6.0.29/webapps/johnson/WEB-INF/lib/
struts2-core-2.2.1.jar!/struts-default.xml:48:178
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.reg
ister(XmlConfigurationProvider.java:232)
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(Str
utsXmlConfigurationProvider.java:101)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContai
ner(DefaultConfiguration.java:180)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
ConfigurationManager.java:66)
        ... 30 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUpl
oadException
        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.reg
ister(XmlConfigurationProvider.java:222)
        ... 33 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileU
ploadException
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1645)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1491)
        ... 37 more
2010-9-25 15:21:06 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2010-9-25 15:21:06 org.apache.catalina.core.StandardContext start
严重: Context [/johnson] startup failed due to previous errors
2010-9-25 15:21:06 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2010-9-25 15:21:06 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2010-9-25 15:21:06 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2010-9-25 15:21:06 org.apache.catalina.startup.Catalina start
信息: Server startup in 1127 ms


在网上查找,说2.1.6开始就要再引入两个包:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar

然后引入这两个包,重启tomcat。还是有问题:

2010-9-25 15:31:07 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory johnson
2010-9-25 15:31:08 com.opensymphony.xwork2.util.logging.commons.CommonsLogger in
fo
信息: Parsing configuration file [struts-default.xml]
2010-9-25 15:31:09 com.opensymphony.xwork2.util.logging.commons.CommonsLogger in
fo
信息: Unable to locate configuration files of the name struts-plugin.xml, skippi
ng
2010-9-25 15:31:09 com.opensymphony.xwork2.util.logging.commons.CommonsLogger in
fo
信息: Parsing configuration file [struts-plugin.xml]
2010-9-25 15:31:09 com.opensymphony.xwork2.util.logging.commons.CommonsLogger in
fo
信息: Parsing configuration file [struts.xml]
2010-9-25 15:31:09 com.opensymphony.xwork2.util.logging.commons.CommonsLogger er
ror
严重: Dispatcher initialization failed
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(Co
ntainerImpl.java:295)
        at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.cons
truct(ContainerImpl.java:431)
        at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBui
lder.java:207)
        at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
        at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBui
lder.java:93)
        at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuild
er.java:487)
        at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuild
er.java:484)
        at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerI
mpl.java:574)
        at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuild
er.java:484)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootst
rapContainer(DefaultConfiguration.java:252)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContai
ner(DefaultConfiguration.java:193)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
ConfigurationManager.java:66)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Di
spatcher.java:371)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
        at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.
java:190)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(Applicatio
nFilterConfig.java:295)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(Applica
tionFilterConfig.java:422)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFi
lterConfig.java:115)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.
java:4001)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
651)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1041)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:964)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:321)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:5
19)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(Co
ntainerImpl.java:293)
        ... 41 more
Caused by: java.lang.ExceptionInInitializerError
        at com.opensymphony.xwork2.ognl.OgnlValueStackFactory.setContainer(OgnlV
alueStackFactory.java:85)
        ... 46 more
Caused by: java.lang.IllegalArgumentException: Javassist library is missing in c
lasspath! Please add missed dependency!
        at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:165)
        ... 47 more
Caused by: java.lang.ClassNotFoundException: javassist.ClassPool
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1645)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1491)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:162)
        ... 47 more
2010-9-25 15:31:09 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2010-9-25 15:31:09 org.apache.catalina.core.StandardContext start
严重: Context [/johnson] startup failed due to previous errors
2010-9-25 15:31:09 org.apache.catalina.loader.WebappClassLoader clearThreadLocal
Map
严重: The web application [/johnson] created a ThreadLocal with key of type [nul
l] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@9cfec1]) and a value
of type [java.lang.Object[]] (value [[Ljava.lang.Object;@11946c2]) but failed to
remove it when the web application was stopped. This is very likely to create a
memory leak.
2010-9-25 15:31:09 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2010-9-25 15:31:09 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2010-9-25 15:31:09 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2010-9-25 15:31:09 org.apache.catalina.startup.Catalina start
信息: Server startup in 2435 ms

然后找到了下面这个帖子:
http://topic.csdn.net/u/20100825/22/bc4344a1-9cd9-45a1-a12d-012a9a3e99b5.html
其中有人回帖:
在使用struts-2.2.1时,需要引入javassist-3.7.ga.jar,而这个在struts-2.2.1\lib下是没有的,需要在struts-2.2.1\apps\struts2-blank-2.2.1.war下的lib中找。

然后引入,重启Tomcat,搞定!

另外的一个回帖说:
把ognl-3.0.jar换成ognl-2.6.11.jar
这个方式也可以。
看来使用ognl-3.0.jar还得再搭配javassist-3.7.ga.jar

注意:此文转帖自:http://space.itpub.net/385592/viewspace-674809

我的异常网推荐解决方案:com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register,http://www.myexception.cn/j2ee/307924.html

热点排行