Struts2.5版本之后Tomcat启动报错问题

转载 2017年10月06日 21:05:43

初次学习Struts2,本着学习最新版本知识的原则,使用了Struts2.5.5版本。使用2.1版本没有问题,但是2.5版本果然会报错,完全靠自学。。。我真是解决两个小时啊!对新手来说上手坑真的比较多。。。

1.导入lib,我们只需要导入一些最小依赖包,下面列出的是我导入的

commons-fileupload-1.3.2.jar

commons-io-2.4.jar

commons-lang3-3.4.jar

commons-logging-1.1.3.jar

freemarker-2.3.23.jar

javassist-3.20.0-GA.jar

ognl-3.1.10.jar

struts2-core-2.5.5.jar

一共是8个包,不要漏掉。。。

(如果是struts2.5版本之前,还需要导入Xwork2包,现在已经合并到struts-core包中)

2.配置Web.xml的问题

[html] view plain copy
 print?
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  5.     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">  
  6.     <display-name></display-name>  
  7.     <welcome-file-list>  
  8.         <welcome-file>result.jsp</welcome-file>  
  9.     </welcome-file-list>  
  10.     <filter>  
  11.         <filter-name>struts2</filter-name>  
  12.         <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  13.   
  14.     </filter>  
  15.     <filter-mapping>  
  16.         <filter-name>struts2</filter-name>  
  17.         <url-pattern>/*</url-pattern>  
  18.     </filter-mapping>  
  19. </web-app>  

注意:在Struts2.5之前,class配置为:<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>,但是在2.5之后,已经取消了ng,改为<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>

在Struts2.5之前使用的是FilterDispatcher过滤器,改版之后可以在StrutsPrepareAndExecuteFilter之后和action执行之前添加自己的过滤器


3.<welcome-file>/result.jsp</welcome-file>

 ' / ' 加不加其实都可以,不影响

4.如果是struts2.5版本之后,会出现无法启动Tomcat的问题

总是抱错:A child container failed during start

下面是我的报错信息

信息: OS Version:            6.1

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Architecture:          amd64

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Java Home:             C:\Program Files\Java\jdk1.8.0_25\jre

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: JVM Version:           1.8.0_25-b18

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: JVM Vendor:            Oracle Corporation

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: CATALINA_BASE:         D:\Practice\Imooc\Java\Struts2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: CATALINA_HOME:         D:\Program Files\apache-tomcat-8.0.28

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dcatalina.base=D:\Practice\Imooc\Java\Struts2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dcatalina.home=D:\Program Files\apache-tomcat-8.0.28

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dwtp.deploy=D:\Practice\Imooc\Java\Struts2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Djava.endorsed.dirs=D:\Program Files\apache-tomcat-8.0.28\endorsed

十一月 16, 2016 11:25:09 下午 org.apache.catalina.startup.VersionLoggerListener log

信息: Command line argument: -Dfile.encoding=GBK

十一月 16, 2016 11:25:09 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent

信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_25\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.8.0_25/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_25/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_25/bin/../jre/lib/amd64;F:\Program Files\Python34\;F:\Program Files\Python34\Scripts;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;D:\Program Files\Brackets\command;F:\Program Files\nodejs\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Program Files\Java\jdk1.8.0_25\jre\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;F:\Program Files\MySQL\MySQL Server 5.7\bin;D:\Program Files\VisualSVN Server\bin;D:\Program Files\TortoiseSVN\bin;.;F:\Program Files\Android\sdk\platform-tools;F:\Program Files\Android\sdk\tools;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Users\Daley\AppData\Roaming\npm;F:\Program Files\Android\apache-ant-1.9.6\bi;F:\Program Files\eclipse;;.

十一月 16, 2016 11:25:09 下午 org.apache.coyote.AbstractProtocol init

信息: Initializing ProtocolHandler ["http-nio-8080"]

十一月 16, 2016 11:25:10 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息: Using a shared selector for servlet write/read

十一月 16, 2016 11:25:10 下午 org.apache.coyote.AbstractProtocol init

信息: Initializing ProtocolHandler ["ajp-nio-8009"]

十一月 16, 2016 11:25:10 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息: Using a shared selector for servlet write/read

十一月 16, 2016 11:25:10 下午 org.apache.catalina.startup.Catalina load

信息: Initialization processed in 1278 ms

十一月 16, 2016 11:25:10 下午 org.apache.catalina.core.StandardService startInternal

信息: Starting service Catalina

十一月 16, 2016 11:25:10 下午 org.apache.catalina.core.StandardEngine startInternal

信息: Starting Servlet Engine: Apache Tomcat/8.0.28

十一月 16, 2016 11:25:11 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom

信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [653] milliseconds.

十一月 16, 2016 11:25:12 下午 org.apache.catalina.core.ContainerBase startInternal

严重: A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/asd]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:192)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)

at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/asd]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

... 6 more

Caused by: java.lang.NoClassDefFoundError: Lorg/apache/logging/log4j/Logger;

at java.lang.Class.getDeclaredFields0(Native Method)

at java.lang.Class.privateGetDeclaredFields(Class.java:2575)

at java.lang.Class.getDeclaredFields(Class.java:1908)

at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)

at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256)

at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:105)

at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:64)

at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334)

at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)

at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5080)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 6 more

Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)

... 20 more


十一月 16, 2016 11:25:12 下午 org.apache.catalina.core.ContainerBase startInternal

严重: A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:192)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)

at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.startup.Catalina.start(Catalina.java:625)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: org.apache.catalina.LifecycleException: A child container failed during start

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)

at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 6 more


十一月 16, 2016 11:25:12 下午 org.apache.catalina.startup.Catalina start

严重: The required Server component failed to start so Tomcat is unable to start.

org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.startup.Catalina.start(Catalina.java:625)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 7 more

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 9 more

Caused by: org.apache.catalina.LifecycleException: A child container failed during start

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)

at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

... 11 more


十一月 16, 2016 11:25:12 下午 org.apache.coyote.AbstractProtocol pause

信息: Pausing ProtocolHandler ["http-nio-8080"]

十一月 16, 2016 11:25:12 下午 org.apache.coyote.AbstractProtocol pause

信息: Pausing ProtocolHandler ["ajp-nio-8009"]

十一月 16, 2016 11:25:12 下午 org.apache.catalina.core.StandardService stopInternal

信息: Stopping service Catalina

十一月 16, 2016 11:25:12 下午 org.apache.coyote.AbstractProtocol destroy

信息: Destroying ProtocolHandler ["http-nio-8080"]

十一月 16, 2016 11:25:12 下午 org.apache.coyote.AbstractProtocol destroy

严重: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"]

java.lang.NullPointerException

at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:305)

at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:481)

at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:823)

at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:532)

at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)

at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)

at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)

at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)

at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:859)

at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)

at org.apache.catalina.startup.Catalina.start(Catalina.java:629)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)


十一月 16, 2016 11:25:12 下午 org.apache.coyote.AbstractProtocol destroy

信息: Destroying ProtocolHandler ["ajp-nio-8009"]

十一月 16, 2016 11:25:12 下午 org.apache.coyote.AbstractProtocol destroy

严重: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"]

java.lang.NullPointerException

at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:305)

at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:481)

at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:823)

at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:532)

at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)

at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)

at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)

at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)

at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:859)

at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)

at org.apache.catalina.startup.Catalina.start(Catalina.java:629)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)


其实是因为少导入了一个包(Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger):log4j-api-2.7.jar 。

加入之后问题解决!

Struts2.5版本之后Tomcat启动报错问题

初次学习Struts2,本着学习最新版本知识的原则,使用了Struts2.5.5版本。使用2.1版本没有问题,但是2.5版本果然会报错,完全靠自学。。。我真是解决两个小时啊!对新手来说上手坑真的比较多...

启动tomcat报错:exception starting filter struts2 unable to load configuration.代码没有任何问题

启动tomcat报错:exception starting filter struts2 unable to load configuration.代码没有任何问题 我的代码没有任何...

【IOS开发填坑】解决更新新版本Xcode之后使用Git报错的问题

更新Xcode以后使用Git报错: bixiaopeng@bixiaopengtekiMacBook-Pro SecondApp$ git pull Agreeing to the Xcode/i...
  • ourpush
  • ourpush
  • 2016年09月28日 22:00
  • 264

关于Struts2.1.6中配置 constant name="struts.devMode" value="true" 在tomcat启动时报错的问题 .

http://blog.csdn.net/axin66ok/article/details/6176000 在网上学习尚学堂Struts2的过程中,遇到了这个问题,当在配置Struts.xml...
  • xu1314
  • xu1314
  • 2012年03月16日 15:31
  • 2391

关于Struts2.1.6中配置 constant name="struts.devMode" value="true" 在tomcat启动时报错的问题

       在网上学习尚学堂Struts2的过程中,遇到了这个问题,当在配置Struts.xml中,启动tomcat的时候报了一个这样的错误严重: Exception starting filter...

eclipse中,更新JDK之后,启动Tomcat报错:

更新到这个版本之后,启动Tomcat报错: 四月 25, 2016 10:13:20 上午 org.apache.catalina.core.AprLifecycleListener lifecyc...

details.jsp页面的 response.addCookie(cookie);报错&tomcat高版本下的Cookie问题

测试Cookie项目显示浏览过商品的的信息时出现的问题报错信息: HTTP Status 500 - Unable to compile class for JSP104: ...

tomcat6+spring2.5+xfire1.2开发webservice报错原因

02 16 15:58:07 ERROR [http-8090-55] binding.PostInvocationHandler - org.codehaus.xfire.fault.XFireFa...
  • linlzk
  • linlzk
  • 2011年02月16日 16:29
  • 1730

使用struts2.5版本遇到的问题

我的环境         Eclipse JavaEE |1.8JDK |Tomcat8.0| 动态web项目3.1| struts2.5.2     struts相关包         我使用的是s...

使用struts2.5版本遇到的问题

使用struts2.5版本遇到的问题 分类:Java  (8469)  (4)  举报  收藏     我的环境         Eclipse JavaEE |1.8JDK |Tomc...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Struts2.5版本之后Tomcat启动报错问题
举报原因:
原因补充:

(最多只允许输入30个字)