(澳门银河官网网址) SpringBoot在Eclipse内能够运行,但是部署在Tomcat8上启动时会有一个logback的异常
澳门银河官网
澳门银河官网
当前位置 : 澳门银河官网 > 澳门银河官网网址

(澳门银河官网网址) SpringBoot在Eclipse内能够运行,但是部署在Tomcat8上启动时会有一个logback的异常

新开发一个项目,我使用了Springboot作为框架,在项目开发期间我一直使用Eclipse来进行测试,期间一切正常,在近日准备部署到本地的Tomcat8 上供客户端开发的时候发现了这个问题,具体异常如下:

23-May-2017 14:32:20.119 严重 [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ucwapi]]
    at org.apache.catalina.util.LifecycleBase.startLifecycleBase.java:167
    at org.apache.catalina.core.ContainerBase.addChildInternalContainerBase.java:752
    at org.apache.catalina.core.ContainerBase.addChildContainerBase.java:728
    at org.apache.catalina.core.StandardHost.addChildStandardHost.java:734
    at org.apache.catalina.startup.HostConfig.deployWARHostConfig.java:952
    at org.apache.catalina.startup.HostConfig$DeployWar.runHostConfig.java:1823
    at java.util.concurrent.Executors$RunnableAdapter.callExecutors.java:511
    at java.util.concurrent.FutureTask.runFutureTask.java:266
    at java.util.concurrent.ThreadPoolExecutor.runWorkerThreadPoolExecutor.java:1142
    at java.util.concurrent.ThreadPoolExecutor$Worker.runThreadPoolExecutor.java:617
    at java.lang.Thread.runThread.java:745
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation class org.apache.logging.slf4j.Log4jLoggerFactory loaded from file:/C:/server/apache-tomcat-8.5.15/webapps/ucwapi/WEB-INF/lib/log4j-slf4j-impl-2.4.1.jar. If you are using WebLogic you will need to add org.slf4j to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.apache.logging.slf4j.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
    at org.springframework.util.Assert.isInstanceOfAssert.java:346
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContextLogbackLoggingSystem.java:221
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerLogbackLoggingSystem.java:213
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitializeLogbackLoggingSystem.java:98
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartedEventLoggingApplicationListener.java:215
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEventLoggingApplicationListener.java:197
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListenerSimpleApplicationEventMulticaster.java:166
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEventSimpleApplicationEventMulticaster.java:138
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEventSimpleApplicationEventMulticaster.java:121
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEventEventPublishingRunListener.java:111
    at org.springframework.boot.context.event.EventPublishingRunListener.startedEventPublishingRunListener.java:60
    at org.springframework.boot.SpringApplicationRunListeners.startedSpringApplicationRunListeners.java:48
    at org.springframework.boot.SpringApplication.runSpringApplication.java:303
    at org.springframework.boot.context.web.SpringBootServletInitializer.runSpringBootServletInitializer.java:149
    at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContextSpringBootServletInitializer.java:129
    at org.springframework.boot.context.web.SpringBootServletInitializer.onStartupSpringBootServletInitializer.java:85
    at org.springframework.web.SpringServletContainerInitializer.onStartupSpringServletContainerInitializer.java:169
    at org.apache.catalina.core.StandardContext.startInternalStandardContext.java:5196
    at org.apache.catalina.util.LifecycleBase.startLifecycleBase.java:150
    ... 10 more

23-May-2017 14:32:20.120 严重 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [C:\server\apache-tomcat-8.5.15\webapps\ucwapi.war]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ucwapi]]
    at org.apache.catalina.core.ContainerBase.addChildInternalContainerBase.java:756
    at org.apache.catalina.core.ContainerBase.addChildContainerBase.java:728
    at org.apache.catalina.core.StandardHost.addChildStandardHost.java:734
    at org.apache.catalina.startup.HostConfig.deployWARHostConfig.java:952
    at org.apache.catalina.startup.HostConfig$DeployWar.runHostConfig.java:1823
    at java.util.concurrent.Executors$RunnableAdapter.callExecutors.java:511
    at java.util.concurrent.FutureTask.runFutureTask.java:266
    at java.util.concurrent.ThreadPoolExecutor.runWorkerThreadPoolExecutor.java:1142
    at java.util.concurrent.ThreadPoolExecutor$Worker.runThreadPoolExecutor.java:617
    at java.lang.Thread.runThread.java:745

Springboot 版本为1.3.5
logback版本为1.1.7

Tomcat7.0 升级至8.0 问题解决

本地打war能运行不?

原因:ClassLoader 的关系,IDE中的ClassLoader 实现与 Spring Boot JarLauncher 不同,因此,加载了不同的jar。log4j-slf4j 与logback 均为 slf4j-api的实现,所以冲突了。

解决方法:移除 log4j-slf4j 依赖(通过Maven

广告位

澳门银河官网