在 Tomcat 中工作 WAR 在 WildFly 中失败
Working WAR in Tomcat fails in WildFly
我有一个 JAVA WAR
文件,之前使用 JDK 7
导出
我在 Tomcat 7
中成功部署了它,即将 bin\startup.bat
当尝试在 WildFly 8
中执行相同操作时(使用 bin\standalone.bat
)我得到一个错误:
我猜相关的错误是
Caused by: java.lang.NoClassDefFoundError:
org/springframework/beans/factory/NoUniqueBeanDefinitionException
Caused by: java.lang.ClassNotFoundException:
org.springframework.beans.factory.NoUniqueBeanDefinitionException from
[Module "deployment.SpringHelloWorld.war:main" from Service Module
Loader]
完整日志:
2015-08-12 17:28:51,552 ERROR [org.jboss.msc.service.fail] (MSC
service thread 1-16) MSC000001: Failed to start service
jboss.undertow.deployment.default-server.default-host./SpringHelloWorld:
org.jboss.msc.service.StartException in service
jboss.undertow.deployment.default-server.default-host./SpringHelloWorld:
Failed to start service at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
[jboss-msc-1.2.2.Final.jar:1.2.2.Final] at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[rt.jar:1.8.0_51] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[rt.jar:1.8.0_51] at java.lang.Thread.run(Unknown Source)
[rt.jar:1.8.0_51] Caused by: java.lang.NoClassDefFoundError:
org/springframework/beans/factory/NoUniqueBeanDefinitionException at
java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.8.0_51]
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
[rt.jar:1.8.0_51] at java.lang.Class.getDeclaredMethods(Unknown
Source) [rt.jar:1.8.0_51] at
org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:159)
at
org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:106)
at
org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:87)
at
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:233)
at
org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:203)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:622)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
at
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
at
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
at javax.servlet.GenericServlet.init(GenericServlet.java:244) at
io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at
org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79)
at
io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at
io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220)
at
io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125)
at
io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:509)
at
org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)
at
org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
[jboss-msc-1.2.2.Final.jar:1.2.2.Final] at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
[jboss-msc-1.2.2.Final.jar:1.2.2.Final] ... 3 more Caused by:
java.lang.ClassNotFoundException:
org.springframework.beans.factory.NoUniqueBeanDefinitionException from
[Module "deployment.SpringHelloWorld.war:main" from Service Module
Loader] at
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213)
[jboss-modules.jar:1.3.3.Final] at
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459)
[jboss-modules.jar:1.3.3.Final] at
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408)
[jboss-modules.jar:1.3.3.Final] at
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389)
[jboss-modules.jar:1.3.3.Final] at
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134)
[jboss-modules.jar:1.3.3.Final] ... 30 more
2015-08-12 17:28:51,569 ERROR
[org.jboss.as.controller.management-operation] (Controller Boot
Thread) JBAS014613: Operation ("deploy") failed - address:
([("deployment" => "SpringHelloWorld.war")]) - failure description:
{"JBAS014671: Failed services" =>
{"jboss.undertow.deployment.default-server.default-host./SpringHelloWorld"
=> "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./SpringHelloWorld:
Failed to start service
Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.NoUniqueBeanDefinitionException from
[Module \"deployment.SpringHelloWorld.war:main\" from Service Module
Loader]"}} 2015-08-12 17:28:51,598 INFO [org.jboss.as.server]
(ServerService Thread Pool -- 28) JBAS018559: Deployed
"SpringHelloWorld.war" (runtime-name : "SpringHelloWorld.war")
2015-08-12 17:28:51,599 INFO [org.jboss.as.controller] (Controller
Boot Thread) JBAS014774: Service status report JBAS014777: Services
which failed to start: service
jboss.undertow.deployment.default-server.default-host./SpringHelloWorld:
org.jboss.msc.service.StartException in service
jboss.undertow.deployment.default-server.default-host./SpringHelloWorld:
Failed to start service
两个 Web 服务器安装都是干净的,根本没有自定义
正如人们可能猜到的那样,我最近对 Java 没有什么经验。
我在这里错过了什么?
编辑: 问题是 v3.1.2 spring-beans 与其他 spring jar 的 4.x.x 版本的混合。将 spring-beans 升级到与其他 jar 相同的版本解决了异常。目前还不清楚为什么它在 Tomcat.
中起作用
您的 war 是否包含 spring-beans 罐子?它找不到的 class org.springframework.beans.factory.NoUniqueBeanDefinitionException
在 http://mvnrepository.com/artifact/org.springframework/spring-beans
中定义
我有一个 JAVA WAR
文件,之前使用 JDK 7
我在 Tomcat 7
中成功部署了它,即将 bin\startup.bat
当尝试在 WildFly 8
中执行相同操作时(使用 bin\standalone.bat
)我得到一个错误:
我猜相关的错误是
Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.NoUniqueBeanDefinitionException from [Module "deployment.SpringHelloWorld.war:main" from Service Module Loader]
完整日志:
2015-08-12 17:28:51,552 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-16) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./SpringHelloWorld: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./SpringHelloWorld: Failed to start service at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_51] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_51] at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_51] Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.8.0_51] at java.lang.Class.privateGetDeclaredMethods(Unknown Source) [rt.jar:1.8.0_51] at java.lang.Class.getDeclaredMethods(Unknown Source) [rt.jar:1.8.0_51] at org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:159) at org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:106) at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:87) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:233) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:203) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:622) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133) at javax.servlet.GenericServlet.init(GenericServlet.java:244) at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79) at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103) at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220) at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125) at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:509) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final] ... 3 more Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.NoUniqueBeanDefinitionException from [Module "deployment.SpringHelloWorld.war:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final] ... 30 more
2015-08-12 17:28:51,569 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "SpringHelloWorld.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./SpringHelloWorld" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./SpringHelloWorld: Failed to start service Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.NoUniqueBeanDefinitionException from [Module \"deployment.SpringHelloWorld.war:main\" from Service Module Loader]"}} 2015-08-12 17:28:51,598 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "SpringHelloWorld.war" (runtime-name : "SpringHelloWorld.war") 2015-08-12 17:28:51,599 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./SpringHelloWorld: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./SpringHelloWorld: Failed to start service
两个 Web 服务器安装都是干净的,根本没有自定义
正如人们可能猜到的那样,我最近对 Java 没有什么经验。
我在这里错过了什么?
编辑: 问题是 v3.1.2 spring-beans 与其他 spring jar 的 4.x.x 版本的混合。将 spring-beans 升级到与其他 jar 相同的版本解决了异常。目前还不清楚为什么它在 Tomcat.
中起作用您的 war 是否包含 spring-beans 罐子?它找不到的 class org.springframework.beans.factory.NoUniqueBeanDefinitionException
在 http://mvnrepository.com/artifact/org.springframework/spring-beans