2017-10-13 223 views
0

我正在嘗試編寫一個非常簡單的groovy &使用gradle處理依賴關係的spring web應用程序。無法在彈簧啓動時啓動嵌入式Tomcat

事情是我無法啓動應用程序,無法弄清楚爲什麼。

以下是我在ReleaseApp.groovy主要方法

package com.ullink.release.config 

import org.springframework.boot.SpringApplication 
import org.springframework.boot.autoconfigure.SpringBootApplication 

@SpringBootApplication(scanBasePackages = "com.ullink.release.*") 
class ReleaseApp { 

static void main(String[] args) { 

    SpringApplication.run(ReleaseApp.class, args) 

    } 
} 

的build.gradle文件

buildscript { 
    dependencies { 
     classpath(group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '1.5.2.RELEASE') 
     classpath([group: 'com.ullink.gradle', name: 'gradle-ullink-plugin', version: '1.31']) 
    } 
} 

apply plugin: 'java-ullink' 
apply plugin: 'groovy' 
apply plugin: 'org.springframework.boot' 
apply plugin: 'sonar-runner-ullink' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'war' 


sourceCompatibility = JavaVersion.VERSION_1_8 

dependencies { 
    compile("org.springframework.boot:spring-boot-starter-web") { 
     exclude module: "logback-classic" 
    } 

    compile(
      [group: 'com.atlassian.jira', name: 'jira-rest-java-client-core', version: '4.0.0'], 
      [group: 'com.atlassian.fugue', name: 'fugue', version: '2.2.1'], 
      [group: 'org.objenesis', name: 'objenesis', version: '2.2'], 
      gradleApi(), 
    ) 

    testCompile(
      [group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4', exclude: [ 
        module: 'groovy-all' 
      ]], 
      [group: 'cglib', name: 'cglib-nodep', version: '3.2.1'], 
    ) 
} 

完整的錯誤堆棧跟蹤是:

Oct 13, 2017 10:59:35 AM org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator <init> 
WARN: HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported 
Oct 13, 2017 10:59:35 AM org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator <init> 
WARN: HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported 
Oct 13, 2017 10:59:36 AM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Tomcat 
Oct 13, 2017 10:59:36 AM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/8.5.11 
Oct 13, 2017 10:59:36 AM org.apache.catalina.core.ContainerBase startInternal 
SEVERE: 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) 
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939) 
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) 
    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:748) 
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) 
    ... 6 more 
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) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 6 more 
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) 
    at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:170) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 8 more 
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; 
    at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1137) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 10 more 

Oct 13, 2017 10:59:36 AM org.apache.catalina.core.ContainerBase startInternal 
SEVERE: 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:939) 
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:343) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:548) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) 
    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:536) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) 
    at org.springframework.boot.SpringApplication$run.call(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) 
    at com.ullink.release.ReleaseApp.main(ReleaseApp.groovy:11) 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) 
    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:748) 
Caused by: org.apache.catalina.LifecycleException: A child container failed during start 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:947) 
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 6 more 

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 
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:536) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) 
    at org.springframework.boot.SpringApplication$run.call(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) 
    at com.ullink.release.ReleaseApp.main(ReleaseApp.groovy:11) 
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:123) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:548) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) 
    ... 12 more 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) 
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:343) 
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99) 
    ... 17 more 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) 
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 19 more 
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) 
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 21 more 
Caused by: org.apache.catalina.LifecycleException: A child container failed during start 
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:947) 
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 23 more 

我懷疑問題依賴完全在build.grade文件中,但我無法弄清楚我是否缺少一些依賴關係或者是否有問題是錯的。

任何幫助將不勝感激!

嵌套例外似乎是:

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

+0

工作你可以分享您的網頁。 xml和pom? –

+0

我沒有pom文件,因爲我使用gradle而不是maven。 –

+0

不要一遍又一遍地問[相同的問題](https://stackoverflow.com/questions/46723751/unable-to-start-springboot-server-due-to-missing-embeddedservletcontainerfactory)! –

回答

0

這個錯誤通常是在dependencies.This對版本不匹配的情況下,我

<dependency> 
    <groupId>javax.validation</groupId> 
    <artifactId>validation-api</artifactId> 
    <version>1.0.0.GA</version> 
</dependency> 

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-validator</artifactId> 
    <version>4.3.1.Final</version> 
</dependency> 
+0

我已經添加了:compile(「javax.validation:validation-api:1.0.0.GA」) compile(「org.hibernate:hibernate-validator:4.3.1.Final」) –

+0

確切的錯誤,沒有改變。 –

+0

你能告訴你使用哪個版本的spring和hibernate嗎?\ –