Mr_PengXuan
Mr_PengXuan
采纳率0%
2019-01-21 22:44 阅读 19.1k

springboot2.1 引入spring-boot-starter-web时启动 报错

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_191]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:914) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1382) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1372) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [na:1.8.0_191]
    at java.util.concurrent.FutureTask.run(FutureTask.java) [na:1.8.0_191]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:907) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:933) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:398) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:415) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) [spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:181) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5041) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1382) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1372) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) [na:1.8.0_191]
    at java.util.concurrent.FutureTask.run(FutureTask.java) [na:1.8.0_191]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:907) [tomcat-embed-core-9.0.14.jar:9.0.14]
    ... 30 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
    at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1178) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    ... 41 common frames omitted

2019-01-21 22:19:30.303 ERROR 30556 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_191]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:914) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:933) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:398) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:106) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:415) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) [spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
    at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:926) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1382) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1372) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_191]
    at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_191]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) ~[na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:907) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    ... 21 common frames omitted
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_191]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:914) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    ... 30 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [NonLoginAuthenticator[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:181) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5041) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1382) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1372) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_191]
    at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_191]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) ~[na:1.8.0_191]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:907) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    ... 30 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
    at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1178) ~[tomcat-embed-core-9.0.14.jar:9.0.14]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.14.jar:9.0.14]
    ... 41 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:57321', transport: 'socket'
2019-01-21 22:19:30.321  INFO 30556 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-01-21 22:19:30.322  WARN 30556 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-01-21 22:19:30.322  INFO 30556 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-21 22:19:30.333 ERROR 30556 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; but it does not exist. Its class, javax.servlet.ServletContext, is available from the following locations:

    jar:file:/C:/Program%20Files%20(x86)/JAVA/JDK/jre/lib/ext/servlet-api.jar!/javax/servlet/ServletContext.class
    jar:file:/C:/Mavn/maven-repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.14/tomcat-embed-core-9.0.14.jar!/javax/servlet/ServletContext.class

It was loaded from the following location:

    file:/C:/Program%20Files%20(x86)/JAVA/JDK/jre/lib/ext/servlet-api.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext


Process finished with exit code 1

idea生成的springboot项目,当pom文件引入spring-boot-starter-web时 启动报错

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • mytwilight mytwilight 2019-01-22 09:58

    网上下载一个servlet-api.jar 放在 file:/C:/Program%20Files%20(x86)/JAVA/JDK/jre/lib/ext/servlet-api.jar 目录下
    提示就是这样

    点赞 评论 复制链接分享
  • tavatimsa tavatimsa 2019-01-22 10:01

    不是引入spring-boot-starter-web报错,是servlet-api.jar这个和你tomcat冲突了,tomcat里面有这个jar包。你看看你maven pom里面添加了
    servlet-api这个没?添加了可以删掉。

    点赞 评论 复制链接分享
  • m0_45372456 m0_45372456 2019-10-03 20:11

    springboot2.1

    点赞 评论 复制链接分享
  • qq_42159155 qq_42159155 2019-12-11 18:08

    你看你jdk有没有servlet-api.jar 把它删了

    点赞 评论 复制链接分享

相关推荐