Spring Boot不适用于JBoss

时间:2013-12-31 15:57:22

标签: java jboss spring-boot

我正在盯着 Spring Boot ,我尝试创建网站上提供的示例(http://projects.spring.io/spring-boot/#quick-start)。当我将示例作为独立应用程序(.jar)运行并在我的Tomcat服务器中作为Web应用程序(.war)运行时,一切正常。

但是当我将在Tomcat上工作的同一个.war文件移动到 JBoss 7.1 服务器时,它就不再起作用了。我收到了这个错误:

Error calling onStartup for servlet container initializer: org.springframework.web.SpringServletContainerInitializer: java.lang.NoSuchMethodError: org.slf4j.bridge.SLF4JBridgeHandler.removeHandlersForRootLogger()V

我不知道为什么会这样。我google'd但找不到任何与Spring Boot相关的东西。有人可以帮帮我吗?完整的堆栈跟踪如下。提前谢谢!

13:43:10,009 WARN  [org.jboss.as.ee] (MSC service thread 1-3) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.springframework.http.server.ServletServerHttpAsyncRequestControl
    at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:606)
    at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:81)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_10-ea]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_10-ea]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_10-ea]

13:43:10,014 WARN  [org.jboss.as.ee] (MSC service thread 1-3) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.springframework.web.context.request.async.StandardServletAsyncWebRequest
    at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:606)
    at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:81)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_10-ea]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_10-ea]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_10-ea]

13:43:10,528 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ScheduledTasks]] (MSC service thread 1-15) Spring WebApplicationInitializers detected on classpath: [hello.HelloWebXml@31518afb]
13:43:10,695 INFO  [org.springframework.boot.autoconfigure.AutoConfigurationReportLoggingInitializer] (MSC service thread 1-15) Nothing to report: ApplicationContext not available
13:43:10,721 ERROR [org.jboss.web] (MSC service thread 1-15) JBAS018202: Error calling onStartup for servlet container initializer: org.springframework.web.SpringServletContainerInitializer: java.lang.NoSuchMethodError: org.slf4j.bridge.SLF4JBridgeHandler.removeHandlersForRootLogger()V
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:70) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.boot.context.initializer.LoggingApplicationContextInitializer.initialize(LoggingApplicationContextInitializer.java:108) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.callNonEnvironmentAwareSpringApplicationInitializers(SpringApplication.java:371) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:291) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:130) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.boot.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:90) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.boot.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:53) [spring-boot-0.5.0.BUILD-SNAPSHOT.jar:0.5.0.BUILD-SNAPSHOT]
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:181) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]
    at org.jboss.as.web.deployment.JBossContextConfig.lifecycleEvent(JBossContextConfig.java:148) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:115) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3845) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_10-ea]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_10-ea]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_10-ea]

13:43:11,154 ERROR [org.jboss.web] (MSC service thread 1-15) JBAS018206: Webapp [/ScheduledTasks] is unavailable due to startup errors
13:43:11,155 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-15) Context [/ScheduledTasks] startup failed due to previous errors
13:43:11,219 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-15) MSC00001: Failed to start service jboss.web.deployment.default-host./ScheduledTasks: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ScheduledTasks: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_10-ea]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_10-ea]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_10-ea]

13:43:11,428 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ScheduledTasks.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ScheduledTasks" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ScheduledTasks: JBAS018040: Failed to start context"}}
13:43:11,469 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-11) JBAS015877: Stopped deployment ScheduledTasks.war in 40ms
13:43:11,470 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./ScheduledTasks: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ScheduledTasks: JBAS018040: Failed to start context

13:43:11,472 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./ScheduledTasks" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./ScheduledTasks: JBAS018040: Failed to start context"}}}}

2 个答案:

答案 0 :(得分:5)

JBoss 7是一个案例,我真的建议你使用别的东西。如果由于某种原因确实需要使用它,那么如果升级到Spring Boot 1.0.0.RC2,则会发现日志记录错误消失。但JBoss仍然存在其他问题。请参阅我在Spring Java Config vs Jboss 7中的评论,了解一些有关下一个可能障碍的帮助。

答案 1 :(得分:3)

这个症状意味着Jboss正在使用不同版本的SL4J而没有这种方法。

你可以做两件事:

  1. 转到Jboss lib文件夹 - >打开清单文件并检查版本提供程序等。 然后去findjar.com并搜索包名。这将告诉您需要此jar - jul-to-slf4j-1.5.5.jar。下载此jar并将其放入Jboss lib文件夹中。

  2. 如果您使用的是maven,请添加以下依赖项

    <dependencies>
        ...
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>1.7.5</version>
        </dependency>
        ...
    </dependencies>