启动springboot,出现Unable to start embedded Tomcat

报错信息

java 复制代码
org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_111]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_111]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:923) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_111]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) [tomcat-embed-core-9.0.69.jar:9.0.69]


org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) ~[spring-boot-2.7.6.jar:2.7.6]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.24.jar:5.3.24]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.6.jar:2.7.6]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) [spring-boot-2.7.6.jar:2.7.6]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) [spring-boot-2.7.6.jar:2.7.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.7.6.jar:2.7.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) [spring-boot-2.7.6.jar:2.7.6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) [spring-boot-2.7.6.jar:2.7.6]
	at com.cennavi.bigdata.App.main(App.java:11) [classes/:na]

问题定位

java 复制代码
Caused by: java.lang.AbstractMethodError: org.apache.jasper.servlet.TldScanner$TldScannerCallback.scan(Lorg/apache/tomcat/Jar;Ljava/lang/String;Z)V
	at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:387) ~[tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:318) ~[tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:270) ~[tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:233) ~[tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) ~[jetty-runner-9.3.20.v20170531.jar:2.3.2]
	at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:106) ~[jetty-runner-9.3.20.v20170531.jar:2.3.2]
	at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:103) ~[jetty-runner-9.3.20.v20170531.jar:2.3.2]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211) ~[tomcat-embed-core-9.0.69.jar:9.0.69]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.69.jar:9.0.69]
	... 35 common frames omitted
  1. 查看报错信息的最后一行,发现在执行TldScanner 这个类下面的方法时,出现omitted,一般这种情况,大概率是发生了jar冲突了。
  2. 如下图所示,查看TldScanner 这个类,出现两处地方都包含,找到报错信息中jetty-runner.jar 所在的依赖。我的工程是在hive-cli这个依赖里面。
  3. 使用Dependency Analyzer,可以方便快速的定位jar。

解决问题

在引入的依赖hive-cli里面,将jetty-runner.jar排除掉即可

java 复制代码
<dependency>
  	<groupId>org.apache.hive</groupId>
   	<artifactId>hive-cli</artifactId>
   	<version>3.1.1</version>
   	<exclusions>
		<exclusion>
       		<artifactId>jetty-runner</artifactId>
        	<groupId>org.eclipse.jetty</groupId>
    	</exclusion>
  	</exclusions>
</dependency>

最后服务正常启动!!!

相关推荐
星就前端叭33 分钟前
【开源】一款基于SpringBoot的智慧小区物业管理系统
java·前端·spring boot·后端·开源
带刺的坐椅33 分钟前
RxSqlUtils(base R2dbc)
java·reactor·solon·r2dbc
silence2501 小时前
深入了解 Reactor:响应式编程的利器
java·spring
weixin_SAG1 小时前
21天掌握javaweb-->第19天:Spring Boot后端优化与部署
java·spring boot·后端
m0_748247551 小时前
SpringMVC跨域问题解决方案
java
Elcker1 小时前
KOI技术-事件驱动编程(Sping后端)
java·spring·架构
GitNohup1 小时前
Spring boot处理跨域问题
java·spring boot·跨域
Just_Paranoid1 小时前
使用 IDE生成 Java Doc
java·开发语言·ide
西海天际蔚蓝2 小时前
递归查询全量分页数据问题
java
俎树振2 小时前
深入理解与优化Java二维数组:从定义到性能提升的全面指南
java·算法