it-swarm.com.ru

Весенний ботинок Catalina LifeCycle Exception

У меня есть приложение SpringBoot для простого веб-сервиса, который подключается к Postgres DB. Но когда я запускаю приложение, оно не запускается и выдает следующее исключение: 

    2016-09-08 11:26:15 INFO  c.t.i.c.Main:659 - No active profile set, falling back to default profiles: default
2016-09-08 11:26:20 ERROR o.a.c.c.ContainerBase:181 - 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:911)
    at org.Apache.catalina.core.StandardHost.startInternal(StandardHost.Java:890)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1403)
    at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1393)
    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: org.Apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:158)
    ... 6 common frames omitted
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]]
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:158)
    at org.Apache.catalina.core.StandardContext.startInternal(StandardContext.Java:5088)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 6 common frames omitted
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [org.Apache.catalina.authenticator.NonLoginAuthenticator[]]
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:158)
    at org.Apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.Java:170)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 8 common frames omitted
Caused by: Java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
    at org.Apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.Java:1085)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 10 common frames omitted
2016-09-08 11:26:20 ERROR o.a.c.c.ContainerBase:181 - A child container failed during start
Java.util.concurrent.ExecutionException: org.Apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
    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:911)
    at org.Apache.catalina.core.StandardEngine.startInternal(StandardEngine.Java:262)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    at org.Apache.catalina.core.StandardService.startInternal(StandardService.Java:422)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    at org.Apache.catalina.core.StandardServer.startInternal(StandardServer.Java:791)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    at org.Apache.catalina.startup.Tomcat.start(Tomcat.Java:356)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.Java:97)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.Java:83)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.Java:530)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.Java:176)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.Java:164)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.Java:134)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:535)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.Java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.Java:759)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.Java:369)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:313)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1185)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1174)
    at com.demo.item.classification.Main.main(Main.Java:12)
Caused by: org.Apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:158)
    at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1403)
    at org.Apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.Java:1393)
    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: org.Apache.catalina.LifecycleException: A child container failed during start
    at org.Apache.catalina.core.ContainerBase.startInternal(ContainerBase.Java:919)
    at org.Apache.catalina.core.StandardHost.startInternal(StandardHost.Java:890)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 6 common frames omitted
2016-09-08 11:26:20 ERROR o.s.b.SpringApplication:838 - 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
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.Java:137)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:535)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.Java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.Java:759)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.Java:369)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:313)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1185)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1174)
    at com.demo.item.classification.Main.main(Main.Java:12)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.Java:116)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.Java:83)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.Java:530)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.Java:176)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.Java:164)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.Java:134)
    ... 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:158)
    at org.Apache.catalina.startup.Tomcat.start(Tomcat.Java:356)
    at org.springframework.boot.context.embedded.Tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.Java:97)
    ... 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:158)
    at org.Apache.catalina.core.StandardServer.startInternal(StandardServer.Java:791)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 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:158)
    at org.Apache.catalina.core.StandardService.startInternal(StandardService.Java:422)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 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:919)
    at org.Apache.catalina.core.StandardEngine.startInternal(StandardEngine.Java:262)
    at org.Apache.catalina.util.LifecycleBase.start(LifecycleBase.Java:152)
    ... 19 common frames omitted

Мой основной класс:

@SpringBootApplication
@EnableAutoConfiguration
public class Main {

    public static void main(String[] args) {
        SpringApplication.run(Main.class);
    }

}

Build.gradle

dependencies {
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
  }    
dependencies {
      compile("org.springframework.boot:spring-boot-starter-web")
      compile("org.springframework.boot:spring-boot-starter-actuator")
      testCompile("org.springframework.boot:spring-boot-starter-test")
      compile 'com.github.alaisi.pgasync:postgres-async-driver:0.9'
      compile "org.postgresql:postgresql:9.4.1208"
      testCompile "org.mockito:mockito-core:1.+"
      testCompile "junit:junit:4.11"
      runtime "org.slf4j:slf4j-simple:1.7.10"
    }

Устранение неполадок, которые я уже пробовал:

  1. Искал несколько проблем с jar/version
  2. Проблема совместимости Tomcat и Java
  3. Вычистил/перезапустил/повторно импортировал проект
  4. Все build.gradle перестановки и комбинации
  5. Проверил, работает ли какое-либо другое приложение на 8080, также изменил порт на 9090, до сих пор не помогает.

Пожалуйста, сообщите мне любую другую причину и устраните проблему.

6
tanmayghosh2507

Добавлены следующие зависимости в classpath:

compile("org.springframework.boot:spring-boot-starter-Tomcat")
compile ("org.springframework:spring-jdbc:4.2.5.RELEASE")

Удалены следующие зависимости в пути к классам:

runtime "org.slf4j:slf4j-simple:1.7.10"
1
tanmayghosh2507

springboot зависит от servlet3 или выше, поэтому вы должны удалить servlet-api-2.5:jar и другие версии ниже 3.0.

Я сделал это успешно, с помощью exclude servlet-api-2.5: jar.

15
tongxin.cui

Следующая зависимость maven устраняет эту ошибку:

included this :
 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-Tomcat</artifactId>
    <version>2.0.0.M5</version>
    </dependency>


removed this :
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
1
Alferd Nobel