启动springboot,出现Unable to start embedded Tomcat

报错信息


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]

问题定位

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排除掉即可

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

最后服务正常启动!!!

你可能感兴趣的:(spring,boot,tomcat,java)