2017-03-27 24 views
2

SpringBoot 응용 프로그램을 빌드하려고합니다.구성 요소를 시작하지 못했습니다 [StandardEngine [Tomcat] .StandardHost [localhost] .TomcatEmbeddedContext []]

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.context.ApplicationContext; 

    @SpringBootApplication 
    public class App { 

     @SuppressWarnings("unused") 
     public static void main(String[] args) throws Exception { 
      ApplicationContext ctx = SpringApplication.run(App.class, args); 
     } 
    } 

하지만, 내가 응용 프로그램을 실행하려고하면, 그것은 나에게 다음과 같은 오류가 발생합니다 :

2017-03-27 13:55:58.281 INFO 8608 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 
2017-03-27 13:55:58.299 INFO 8608 --- [   main] o.apache.catalina.core.StandardService : Starting service Tomcat 
2017-03-27 13:55:58.302 INFO 8608 --- [   main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11 
2017-03-27 13:55:58.554 ERROR 8608 --- [cat-startStop-1] 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_73] 
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_73] 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939) ~[tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_73] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_73] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_73] 
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_73] 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    ... 6 common frames omitted 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099) ~[tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    ... 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:167) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:170) ~[tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    ... 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:1137) ~[tomcat-embed-core-8.5.11.jar:8.5.11] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.11.jar:8.5.11] 
    ... 10 common frames omitted 

내 현재의 pom.xml 파일은 다음과 같다 :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>XXXX</groupId> 
    <artifactId>XXXX</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 

<!-- JSON --> 
<dependency> 
    <groupId>com.googlecode.json-simple</groupId> 
    <artifactId>json-simple</artifactId> 
    <version>1.1.1</version> 
</dependency> 

<dependency> 
    <groupId>commons-lang</groupId> 
    <artifactId>commons-lang</artifactId> 
    <version>2.2</version> 
</dependency> 

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-client</artifactId> 
    <version>1.19.3</version> 
</dependency > 

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-json</artifactId> 
    <version>1.19.3</version> 
</dependency> 

<!-- REST Services --> 
    <dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter</artifactId> 
    <version>1.5.0.RELEASE</version> 
</dependency> 

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-web</artifactId> 
    <version>1.5.0.RELEASE</version> 
</dependency> 

<!-- <dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-tomcat</artifactId> 
    <version>1.5.0.RELEASE</version> 
</dependency> --> 


    <!-- SLF4J Logging --> 
    <dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-api</artifactId> 
    <version>1.6.4</version> 
    <scope>compile</scope> 
    </dependency> 

<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>jcl-over-slf4j</artifactId> 
    <version>1.6.4</version> 
    <scope>runtime</scope> 
    </dependency> 

    <dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-log4j12</artifactId> 
    <version>1.6.4</version> 
    <scope>runtime</scope> 
    </dependency> 

    </dependencies> 

    <build> 
    <sourceDirectory>src</sourceDirectory> 
    <plugins> 

    <!-- Set a compiler level --> 
    <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.3</version> 
     <configuration> 
     <source>1.8</source> 
     <target>1.8</target> 
     </configuration> 
    </plugin> 
    </plugins> 
</build> 
</project> 

언급 한 바와을 SO 지부에서, (저지) 제거, (포함 된 바람둥이) 종속성 추가를 시도했습니다. 그러나이 오류는 변경 사항에 영향을 미치지 않는 것으로 보입니다.

나는 또한 시도하고 봄 자습서에서 다른 간단한 프로젝트 (응용 프로그램)이 (두 개의 번호를 추가하려면)이이 완전히 잘 작동 다음의 pom.xml을

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>SpringBootDemoProject</groupId> 
    <artifactId>SpringBootDemoProject</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <dependencies> 
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter --> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter</artifactId> 
    <version>1.5.0.RELEASE</version> 
</dependency> 
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web --> 
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-web</artifactId> 
    <version>1.5.0.RELEASE</version> 
</dependency> 

    </dependencies> 
    <build> 
    <sourceDirectory>src</sourceDirectory> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.3</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

있습니다. 왜 이런 경우에 대한 포인터?

+0

을 확인하시기 바랍니다 귀하의 응용 프로그램 클래스에서 SpringBootServletInitializer를 확장하려고 -api.jar'를 의존성 목록의 javax.servlet.ServletContext.getVirtualServerName() Ljava/lang/String;에 저장하십시오. 난 당신이 버전 3.x 생각하지만 2.1이 필요합니다 – Jens

+0

** javax.servlet ** 내부적으로 버전 3.0.1 사용하는 다른 라이브러리를 사용합니다. 나는 에서 javax.servlet'내 pom.xml 파일을 수정 한 2.2 는'또한 도서관' \t \t \t 에서 javax.servlet 에 추가 서블릿 API를 \t \t javax.servlet-api \t'. 그러나 오류는 여전히 동일합니다. – Betafish

+0

lib가 사용되는 종속성을 조사하십시오. – Jens

답변

1

ur classpath에 호환되지 않는 버전의 Servlet API가있는 것 같습니다. 이것은 Jersey 병에 대한 의존성 일 수 있습니다. 스프링 부트 시동기에서 저지 스타터를 당겨보십시오.

org.springframework.boot : spring-boot-starter-jersey 

이렇게하면 올바른 버전을 클래스 경로로 가져올 수 있습니다.

0

동일한 문제가 있었지만, 아래에 설명 된대로 수정되었습니다. 다음 종속성 중 하나가 범인입니다.

<!-- dependency> 
    <groupId>me.fhir</groupId> 
    <artifactId>fhir</artifactId> 
    <version>0.12.0-RELEASE</version> 
</dependency--> 
<!-- dependency> 
    <groupId>com.fasterxml.jackson.core</groupId> 
    <artifactId>jackson-databind</artifactId> 
    <version>2.8.8</version> 
</dependency--> 
<!-- dependency> 
    <groupId>com.fasterxml.jackson.core</groupId> 
    <artifactId>jackson-core</artifactId> 
    <version>2.8.8</version> 
</dependency--> 
0

내 생각 엔 당신이 이클립스의 Spring Boot Project template 내에서 제공되는 기본 ServletInitializer 클래스를 사용할 필요가있다. Spring Boot Starter Project 템플릿에 지정된대로 ServletInitializer 클래스를 사용하지 않는 경우

//SpringBootApplication.java 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 

@SpringBootApplication 
public class SpringBootApplication { 

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

//ServletInitializer.java 
public class ServletInitializer extends SpringBootServletInitializer { 

    @Override 
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 
     return application.sources(SpringBootApplication.class); 
    } 

} 

,

public class App extends SpringBootServletInitializer 

당신은 호환되지 않는`서블릿이 비슷한 대답을 here