SpringBoot启动Tomcat失败:UnabletostartembeddedTomcat
异常描述
之前项⽬是dubbo的,分为两个服务,service数据层和web请求控制,使⽤dubbo互相调⽤的,现在要把dubbo去掉,使⽤SpringCloud的eureka了,要把两个合并成
⼀个项⽬,这⾥并不是要把所有代码复制过去,⽽是把service使⽤maven引⽤到web项⽬⾥⾯,然后修改对应的配置和包路劲,启动的时候,竟然报错了,编译是没
有任何问题的。
10:02:26.349 logback [main] INFO o.StandardEngine - Starting Servlet Engine: Apache Tomcat/8.5.23
10:02:26.463 logback [Tomcat-startStop-1] ERROR o.ContainerBase - A child container failed during start
urrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
at port(Unknown Source)
at (Unknown Source)
at org.ContainerBase.startInternal(ContainerBase.java:939)
at org.StandardHost.startInternal(StandardHost.java:872)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.ContainerBase$StartChild.call(ContainerBase.java:1409)
at urrent.FutureTask.run(Unknown Source)
at urrent.ThreadPoolExecutor.runWorker(Unknown Source)
at urrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.StandardContext.startInternal(StandardContext.java:5117)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.authenticator.NonLoginAuthenticator[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.StandardPipeline.startInternal(StandardPipeline.java:182)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 8 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.VirtualServerName()Ljava/lang/String;
at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1141)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 common frames omitted
10:02:26.464 logback [main] ERROR o.ContainerBase - A child container failed during start
urrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start compo
nent [StandardEngine[Tomcat].StandardHost[localhost]]
at port(Unknown Source)
at (Unknown Source)
at org.ContainerBase.startInternal(ContainerBase.java:939)
at org.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367)
at org.at.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99)
at org.at.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84)
at org.TomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554)
at org.EmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179)
at org.t.ateEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.t.Refresh(EmbeddedWebApplicationContext.java:134)
at t.fresh(AbstractApplicationContext.java:537)
at org.t.fresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.fresh(SpringApplication.java:693)
at org.springframework.freshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.gwghk.base.platform.dfs.Application.main(Application.java:22)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(Unknown Source)
flect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
springcloud和springbootat flect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.ContainerBase$StartChild.call(ContainerBase.java:1409)
at urrent.FutureTask.run(Unknown Source)
at urrent.ThreadPoolExecutor.runWorker(Unknown Source)
at urrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.ContainerBase.startInternal(ContainerBase.java:948)
at org.StandardHost.startInternal(StandardHost.java:872)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 common frames omitted
10:02:26.465 logback [main] WARN o.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: t.ApplicationContextException: Unabl iner; nested exception is org.t.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
10:02:26.485 logback [main] INFO o.s.b.a.l.AutoConfigurationReportLoggingInitializer -
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
10:02:26.492 logback [main] ERROR o.s.boot.SpringApplication - Application startup failed
t.ApplicationContextException: Unable to start embedded container; nested exception is org.t.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.t.Refresh(EmbeddedWebApplicationContext.java:137)
at t.fresh(AbstractApplicationContext.java:537)
at org.t.fresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.fresh(SpringApplication.java:693)
at org.springframework.freshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.gwghk.base.platform.dfs.Application.main(Application.java:22)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(Unknown Source)
flect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at flect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.t.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.at.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:123)
at org.at.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84)
at org.TomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554)
at org.EmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179)
at org.t.ateEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.t.Refresh(EmbeddedWebApplicationContext.java:134)
... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367)
at org.at.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99)
... 21 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 23 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 25 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.ContainerBase.startInternal(ContainerBase.java:948)
at org.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 27 common frames omitted
异常分析
刚开始有点蒙蔽,之前项⽬⼀直可以运⾏,怎么就报错了呢,⽇了狗了,于是乎各种百度⾕歌的,⼀顿查,基本上两个答案:
1. servlet-api-xxx.jar包冲突
2. servlet-api-xxx.jar版本问题
各种修改了以后,根本解决不了,看来只能靠⾃⼰了,有开始检查l,⽬前只能从l⼊⼿了检查了:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0"
xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dfs-parent</artifactId>
<groupId>com.gwghk.base.platform</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../l</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dfs-api</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
......
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
</project>
我家pom是这样的,发现缺少两个属性配置的,没有<groupId>xxx</groupId>和<packaging>jar</packaging>。
其实之前都看到这个问题了,因为这项⽬是我修改别⼈的代码,就没在乎这个,以为没关系,然后我就加上试试看,是不是这个问题:<artifactId>dfs-api</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>com.gwghk.base.platform</groupId>
<packaging>jar</packaging>
再重新编译⼀次启动试试看,卧槽,竟然成功了,就这个破问题,解决了⼀天
解决办法
问题就出现在pom配置不严谨,该有的还是要有的,不要瞎JB省略。
在pom中添加<groupId>xxx</groupId>和<packaging>jar</packaging>就可以正常启动了:
<artifactId>dfs-api</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>com.gwghk.base.platform</groupId>
<packaging>jar</packaging>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论