问题详情
项目中要增加许多新功能,添加了许多依赖,代码初步写好开始调试,发现spring-boot的服务启动失败
报错信息
error: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
问题初步定位
- 根本原因是在异常信息的最后一个异常堆栈的第一行会打印出来,所以解决问题之前还是要找到问题的根本原因才行
- 根本原因是:
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:378) ~[tomcat-embed-core-9.0.27.jar:9.0.27] at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
- 发现java.lang.AbstractMethodError 是指:Thrown when an application tries to call an abstract method, 即 运行时调用了抽象方法导致的,所以初步判断是jar包冲突导致
问题最终定位
- 发生冲突的是类StandardJarScanner,于是就看了一下 StandardJarScanner 类,发现有两个同名类,一个是tomcat里的,一个是jetty-running里的。很明显,两个jar包因为同名类冲突,导致jvm不知道去加载哪一个,导致tomcat启动失败。
问题解决
-
在引入的hive-jdbc 包中排除掉jetty-runner.jar 即可。
<!-- hive-jar --> <dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-jdbc</artifactId> <version>2.1.1-cdh6.3.2</version> <exclusions> <exclusion> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-runner</artifactId> </exclusion> </exclusions> </dependency> <dependency>
-
最后,服务器正常启动