web-dev-qa-db-fra.com

Botte de Printemps Catalina LifeCycle Exception

J'ai une application SpringBoot pour un service Web simple qui se connecte à Postgres DB. Mais lorsque j'exécute l'application, elle ne démarre pas et lève l'exception suivante: 

    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

Ma classe principale:

@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"
    }

Les dépannages que j'ai déjà essayés:

  1. A recherché plusieurs problèmes de jar/version
  2. Problème de compatibilité entre Tomcat et Java
  3. Nettoyé/Redémarré/Réimporté le projet
  4. Toutes les permutations et combinaisons de build.gradle
  5. Vérifié si une autre application est en cours d'exécution sur 8080, également changé le port à 9090, toujours pas d'aide.

S'il vous plaît, dites-moi toute autre raison et corrigez le problème.

6
tanmayghosh2507

Ajout des dépendances suivantes dans le classpath:

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

Suppression des dépendances suivantes dans le chemin de classe:

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

springboot dépend de servlet3 ou supérieur, vous devriez donc supprimer servlet-api-2.5:jar et les versions inférieures à 3.0.

Je l’ai fait avec succès, en excluant servlet-api-2.5: jar.

15
tongxin.cui

La dépendance maven suivante a résolu cette erreur:

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