SpringBoot-默认tomcat版本启动失败解决方法

本文介绍使用是springboot时由于默认配置的tomcat版本问题导致启动失败的两个报错:
- Unable to start embedded Tomcat
- java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
的解决方法。也是更改springboot默认tomcat版本的方法。

基本环境

jdk7 springBoot版本:1.5.12.RELEASE

报错

在使用springBoot启动时,报错:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.16.RELEASE.jar:4.3.16.RELEASE]

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at com.mym.App.main(App.java:14) [classes/:na]

Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat

    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:138) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:87) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    ... 8 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) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:114) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    ... 13 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) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    ... 15 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) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    ... 17 common frames omitted

Caused by: org.apache.catalina.LifecycleException: A child container failed during start

    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:949) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.29.jar:8.5.29]

    ... 19 common frames omitted

</init>

原因

是因为springBoot内配置的tomcat版本太高,jdk不适应,造成相关jar包冲突

笔者环境:jdk7+spring默认tomcat版本
springboot的依赖版本如下

?

1

2

3

4

5

<parent>

  <groupid>org.springframework.boot</groupid>

  spring-boot-starter-parent</artifactid>

  <version>1.5.12.RELEASE</version>

</parent>

可以看到启动信息中依赖的spring版本是4.3.16

解决

配置好自己适配的tomcat版本
即让springboot放弃默认配置版本即可。配置如下

?

1

2

3

4

5

6

<properties>

  <project.build.sourceencoding>UTF-8</project.build.sourceencoding>

  <maven.compiler.source>1.7</maven.compiler.source>

  <maven.compiler.target>1.7</maven.compiler.target>

  <tomcat.version>7.0.86</tomcat.version>

</properties>

若仍然报错如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.16.RELEASE.jar:4.3.16.RELEASE]

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at com.mym.App.main(App.java:14) [classes/:na]

Caused by: java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

    at org.apache.catalina.util.LifecycleBase.<clinit>(LifecycleBase.java:37) ~[tomcat-embed-core-7.0.86.jar:7.0.86]

    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:169) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.12.RELEASE.jar:1.5.12.RELEASE]

    ... 8 common frames omitted

Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory

    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_80]

    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_80]

    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_80]

    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_80]

    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[na:1.7.0_80]

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_80]

    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[na:1.7.0_80]

    ... 12 common frames omitted</clinit>

因为tocmat缺少jar包,则仍需一个依赖

?

1

2

3

4

5

<dependency>

  <groupid>org.apache.tomcat</groupid>

  tomcat-juli</artifactid>

  <version>${tomcat.version}</version>

</dependency>

发布了47 篇原创文章 · 获赞 103 · 访问量 147万+
展开阅读全文

编程菜鸟一枚,请问各位大神这是怎么回事。自己搭建spring-boot的时候启动start报错

09-14

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]] Caused by: java.lang.IllegalStateException: java.lang.NullPointerException Caused by: java.lang.NullPointerException: null 2016-09-14 14:07:52.047 ERROR 8912 --- [ restartedMain] 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]] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]] Caused by: org.apache.catalina.LifecycleException: A child container failed during start 2016-09-14 14:07:52.047 WARN 8912 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 2016-09-14 14:07:52.094 ERROR 8912 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]] Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]] Caused by: org.apache.catalina.LifecycleException: A child container failed during start 问答

sprin boot 启动内嵌tomcat 报错。

03-21

[ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'webMetricsFilter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'logHandlerInterceptor': Unsatisfied dependency expressed through field 'dubboService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dubboService' defined in URL [jar:file:/data/sjdata_tlsy/jars/backend-api/backend-api-1.0.1.jar!/BOOT-INF/classes!/com/shengjie/backend/util/DubboService.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: dubboService; nested exception is java.lang.IllegalStateException: Failed to check the status of the service com.shengjie.dubbo.agents.IAgentsService. No provider available for the service com.shengjie.dubbo.agents.IAgentsService:1.0.0 from the url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=backend-api&dubbo=2.6.0&interface=com.shengjie.dubbo.agents.IAgentsService&methods=findByAgent,findByGameId&pid=3423&register.ip=172.16.0.14&revision=1.0.1&side=consumer&timestamp=1553109052423&version=1.0.0 to the consumer 172.16.0.14 use dubbo version 2.6.0 2019-03-21 03:10:52.828 WARN 3423 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat 2019-03-21 03:10:52.844 INFO 3423 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-03-21 03:10:52.853 ERROR 3423 --- [ main] o.s.boot.SpringApplication : Application startup failed 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:153) ~[spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.0.2.RELEASE.jar!/:5.0.2.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138) ~[spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751) [spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387) [spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M7.jar!/:2.0.0.M7] at com.shengjie.backend.BackendApiApplication.main(BackendApiApplication.java:22) [classes!/:1.0.1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [backend-api-1.0.1.jar:1.0.1] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [backend-api-1.0.1.jar:1.0.1] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [backend-api-1.0.1.jar:1.0.1] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [backend-api-1.0.1.jar:1.0.1] Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat 问答

今天突然启动tomcat时出现问题

07-11

具体错误信息: 严重: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"] java.lang.NullPointerException at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:315) at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:491) at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:896) at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:551) at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:879) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.startup.Catalina.start(Catalina.java:634) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485) 百度了许多 想了很久 仍未解答 我尝试了一些步骤: 1.删除发布在tomcat的项目 然后启动tomcat能正常运行 这一点可排除端口号被占用的情况。 2.我的项目只有一个 然后目前大量怀疑是项目的问题 网上说是web.xml或者哪里的配置问题 我不这么认为 因为项目已经运行了一段时间了 今天是服务器突然启动不了 而且我没有在web.xml中配置过servlet 都是在Servlet.java开头写@WebServlet 而且原来已经运行过很多次了 3.尝试过更换tomcat 我的是8.0 换成6.0后还是出现相同问题 所以我排除tomcat的问题 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览