启动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>

最后服务正常启动!!!

相关推荐
测开小菜鸟31 分钟前
使用python向钉钉群聊发送消息
java·python·钉钉
P.H. Infinity1 小时前
【RabbitMQ】04-发送者可靠性
java·rabbitmq·java-rabbitmq
生命几十年3万天2 小时前
java的threadlocal为何内存泄漏
java
caridle2 小时前
教程:使用 InterBase Express 访问数据库(五):TIBTransaction
java·数据库·express
^velpro^2 小时前
数据库连接池的创建
java·开发语言·数据库
苹果醋32 小时前
Java8->Java19的初步探索
java·运维·spring boot·mysql·nginx
秋の花2 小时前
【JAVA基础】Java集合基础
java·开发语言·windows
小松学前端2 小时前
第六章 7.0 LinkList
java·开发语言·网络
Wx-bishekaifayuan2 小时前
django电商易购系统-计算机设计毕业源码61059
java·spring boot·spring·spring cloud·django·sqlite·guava
customer082 小时前
【开源免费】基于SpringBoot+Vue.JS周边产品销售网站(JAVA毕业设计)
java·vue.js·spring boot·后端·spring cloud·java-ee·开源