启动时子容器失败 java.util.concurrent.ExecutionException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28102134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A child container failed during start java.util.concurrent.ExecutionException
提问by zzz2991
I tried to create/run a basic JSP and ran into the following error. I saw that other people have had similar problems, however, I haven't been able to find (or properly implement) a solution to the problem at hand yet. Any help would be appreciated!
我试图创建/运行一个基本的 JSP 并遇到以下错误。我看到其他人也有类似的问题,但是,我还没有能够找到(或正确实施)解决手头问题的方法。任何帮助,将不胜感激!
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SimpleServletProject]]
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:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
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[/SimpleServletProject]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 6 more
Caused by: java.lang.NoClassDefFoundError: HttpServletRequest
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
at java.lang.Class.getDeclaredMethods(Class.java:1967)
at org.apache.catalina.util.Introspection.getDeclaredMethods(Introspection.java:127)
at org.apache.catalina.startup.WebAnnotationSet.loadMethodsAnnotation(WebAnnotationSet.java:287)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:415)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:892)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5380)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: java.lang.ClassNotFoundException: HttpServletRequest
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
... 20 more
Jan 22, 2015 9:04:06 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: 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:1123)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
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:321)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
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:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
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:1131)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Jan 22, 2015 9:04:06 PM org.apache.catalina.startup.Catalina start
SEVERE: 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:689)
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:321)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
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:739)
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:443)
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:1131)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
Jan 22, 2015 9:04:06 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jan 22, 2015 9:04:06 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 22, 2015 9:04:06 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jan 22, 2015 9:04:06 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jan 22, 2015 9:04:06 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
回答by Saif Asif
You must have packaged the servlet-api.jar
along with the other libraries in your war file. You can verify this by opening up your war file and navigating to the WEB-INF/lib folder.
您必须servlet-api.jar
在 war 文件中将 与其他库一起打包。您可以通过打开您的 war 文件并导航到 WEB-INF/lib 文件夹来验证这一点。
Ideally, you should not provide the servlet-api jar. The container, in your case Tomcat, is responsible for providing it at deploy time to your application. If you try to provide it as well, then issues arise due to version mismatch etc. Best practise is to just avoid packaging it. Remove it from the WEB-INF/lib.
理想情况下,您不应提供 servlet-api jar。容器(在您的案例中为 Tomcat)负责在部署时将其提供给您的应用程序。如果您也尝试提供它,那么由于版本不匹配等原因会出现问题。最佳实践是避免打包它。从 WEB-INF/lib 中删除它。
Additional Information
附加信息
If you are using maven for your packaging, then simply add the provided
tag with the dependency and maven will make sure not to package it in the final war file. Something like
如果您使用 maven 进行打包,那么只需添加provided
带有依赖项的标签,maven 将确保不会将其打包到最终的 war 文件中。就像是
<dependency>
<artifact>..
<group> ...
<version> ...
<scope>provided</scope>
</<dependency>
回答by Mahender Yadav
Your webapp has servletcontainer specific libraries like servlet-api.jar file in its /WEB-INF/lib. This is not right.
您的 Web 应用程序在其 /WEB-INF/lib 中具有 servletcontainer 特定库,例如 servlet-api.jar 文件。这个不对。
Remove them all.
将它们全部删除。
The /WEB-INF/lib should contain only the libraries specific to the webapp, not to the servletcontainer. The servletcontainer (like Tomcat) is the one who should already provide the servletcontainer specific libraries.
/WEB-INF/lib 应该只包含特定于 webapp 的库,而不是 servletcontainer。servletcontainer(如Tomcat)应该已经提供了servletcontainer 特定的库。
If you supply libraries from an arbitrary servletcontainer of a different make/version, you'll run into this kind of problems because your webapp wouldn't be able to run on a servletcontainer of a different make/version than where those libraries are originated from.
如果您从不同品牌/版本的任意 servletcontainer 提供库,您将遇到此类问题,因为您的 web 应用程序将无法在与这些库的来源不同的品牌/版本的 servletcontainer 上运行.
How to solve:In Eclipse Right click on the project in eclipse Properties -> Java Build Path -> Add library -> Server Runtime Library -> Apache Tomcat
如何解决:在Eclipse中在eclipse中右键项目属性->Java Build Path->添加库->服务器运行时库->Apache Tomcat
Im Maven Project:-
我是 Maven 项目:-
add follwing line in pom.xml file
在 pom.xml 文件中添加以下行
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${default.javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${default.javax.servlet.jsp.version}</version>
<scope>provided</scope>
</dependency>
回答by jetty
I faced similar issue with similar logs. I was using JDK 1.6 with apache tomcat 7. Setting java_home to 1.7 resolved the issue.
我遇到了类似日志的类似问题。我在 apache tomcat 7 中使用 JDK 1.6。将 java_home 设置为 1.7 解决了这个问题。
回答by Raj Shekar
check if you JAVA_HOME is set to 1.7 or below. because tomcat 7 is not compatible with jdk 1.8
检查您的 JAVA_HOME 是否设置为 1.7 或以下。因为 tomcat 7 不兼容 jdk 1.8
This worked for me
这对我有用
回答by Jo?o Matos
This is what worked for me:
这对我有用:
1) add commons-logging.jar to the WEB-INF/lib folder
1) 将 commons-logging.jar 添加到 WEB-INF/lib 文件夹
2) Add this jar as a maven dependency, e.g. add this to the pom.xml:
2)将此jar添加为maven依赖项,例如将其添加到pom.xml:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
3) Maven install
3) Maven 安装
4) Run the server.
4) 运行服务器。
Hope it helps.
希望能帮助到你。
回答by anand mishra
Some time this problem occur due to incompatible java version and tomcat version.Choose the compatible version of both.
有一段时间会出现这个问题,是因为java版本和tomcat版本不兼容。选择两者兼容的版本。
回答by Jov
Delete the project named Servers (or Servers1, Servers2 which contains your server.xml), find it in Package Explorer(workspace)
删除名为 Servers 的项目(或 Servers1、Servers2 包含您的 server.xml),在 Package Explorer(workspace) 中找到它
Remove server from Eclipse :Go to Window > Preferences > Server > Runtime Environment, here remove the server your are using from eclipse and add it again(doing this will create a new Server project folder in Eclipse) ,
从 Eclipse 中删除服务器:转到 Window > Preferences > Server > Runtime Environment,在这里从 Eclipse 中删除您正在使用的服务器并再次添加它(这样做将在 Eclipse 中创建一个新的 Server 项目文件夹),
Remove server from Project :Also remove the server in your project(Build path > configuration path > Java Build path) and add again.
从项目中删除服务器:同时删除项目中的服务器(构建路径 > 配置路径 > Java 构建路径)并再次添加。
now you got a fresh Server project which will not have Multiple Context on its server.xml, only deleting duplicate path in server.xml solved the exixting issue but still server dint start, by doing this Server started(Apache Tomcat v7) and worked normal
现在你有了一个新的服务器项目,它的 server.xml 上不会有多个上下文,只删除 server.xml 中的重复路径解决了现有问题,但服务器仍然启动,通过执行此服务器启动(Apache Tomcat v7)并正常工作
And i dont know whether this is good practice or not, i am a starter in programming.
而且我不知道这是否是好的做法,我是编程的初学者。
回答by Arindam
Faced the same issue. Changed the JRE to the correct 1.8 version and do a maven clean and build resolve the issue. You may need to change the Project Facet and verify the correct path.
面临同样的问题。将 JRE 更改为正确的 1.8 版本并执行 maven clean 并构建解决问题。您可能需要更改 Project Facet 并验证正确的路径。
回答by Shubham Gupta
I faced similar issue and it was caused because I had written WebServlet Path in the .java file as well as in the web.xml . Removing it from any one location works fine for me.
我遇到了类似的问题,这是因为我在 .java 文件和 web.xml 中编写了 WebServlet 路径。从任何一个位置删除它对我来说都很好。
In the .java file
在 .java 文件中
@WebServlet("/index1.jsp")
and in web.xml
并在 web.xml
<servlet>
<servlet-name>Logout</servlet-name>
<servlet-class>tpc.Logout</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Logout</servlet-name>
<url-pattern>/index1.jsp</url-pattern>
</servlet-mapping>
回答by In Dra_ 0509
- download commons-logging-1.1.1.jar.
- Go to Your project,build path, configure build path, java build path.
- Add external jars.. add commons-logging-1.1.1.jar
- click on apply, ok
- Go to project, properties, Deployment Assembly, Click on add,Java build path entries, next, select commons logging jar,ok,,apply, ok..
- Delete server,clean ur proejct, add server, Run your project.
- 下载commons-logging-1.1.1.jar。
- 转到您的项目,构建路径,配置构建路径,java 构建路径。
- 添加外部 jars.. 添加 commons-logging-1.1.1.jar
- 点击申请,ok
- 转到项目,属性,部署程序集,单击添加,Java 构建路径条目,下一步,选择 commons logging jar,ok,,apply,ok..
- 删除服务器,清理你的项目,添加服务器,运行你的项目。