经过长时间的搜索,没有回答我的案子,我在这里。 尝试将“Struts 2 + Maven + Spring”WAR项目部署到Wildfly 11中,使用Eclipse Oxigen的默认值。
堆栈如下:
15:04:27,325 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "MSDB.war" (runtime-name: "MSDB.war")
15:04:30,148 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."MSDB.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."MSDB.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "MSDB.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.springframework.web.context.ContextLoader with ClassLoader ModuleClassLoader for Module "deployment.MSDB.war" from Service Module Loader
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:78)
at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:57)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:106)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:91)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:76)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more
Caused by: java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:72)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
... 10 more
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.access.BeanFactoryReference from [Module "deployment.MSDB.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 15 more
15:04:30,150 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 4) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "MSDB.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"MSDB.war\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"MSDB.war\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.springframework.web.context.ContextLoader with ClassLoader ModuleClassLoader for Module \"deployment.MSDB.war\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference;
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.access.BeanFactoryReference from [Module \"deployment.MSDB.war\" from Service Module Loader]"}}
15:04:30,151 ERROR [org.jboss.as.server] (External Management Request Threads -- 4) WFLYSRV0021: Deploy of deployment "MSDB.war" was rolled back with the following failure message:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"MSDB.war\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"MSDB.war\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.springframework.web.context.ContextLoader with ClassLoader ModuleClassLoader for Module \"deployment.MSDB.war\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference;
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.access.BeanFactoryReference from [Module \"deployment.MSDB.war\" from Service Module Loader]"}}
15:04:30,268 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0028: Stopped deployment MSDB.war (runtime-name: MSDB.war) in 116ms
pom.xml目前是这样的(在插入许多额外的依赖项之后,来自之前在网上搜索的尝试):
<project xmlns="http://maven.apache.org/POM/4.0.0" mlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SBMC</groupId>
<artifactId>MSDB</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MSDB</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.34</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.3.16.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.0.RELEASE</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
</dependencies>
<build>
<finalName>MSDB</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>5.0</version>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin> -->
</plugins>
</build>
</project>
我搜索了很多,但我找不到任何解决了我的问题。
答案 0 :(得分:0)
这里可能存在spring-core依赖问题。除非你的类路径中有spring-core,否则我建议将依赖范围更改为default(或jar)而不是运行时。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.0.RELEASE</version>
</dependency>
答案 1 :(得分:0)
我遇到了这个问题,我试图将war文件部署到tomcat 8,在我的情况下,我使用的库之一对spring-context有依赖性,它引入了4.3.3版本,在这个版本中有类
public class ContextBeanFactoryReference implements BeanFactoryReference
正如您所发现的BeanFactoryReference
在版本5中不存在。
我可以看到你已经有了弹簧上下文版本5,只需仔细检查你的依赖关系并确保只有spring版本5而没有其他版本。
如果其他图书馆引入了其他图书馆,您可以使用
将其排除<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
这解决了我的问题,感觉你的问题类似。
答案 2 :(得分:0)
您可能在项目中添加了一些弹簧框架工作库indirectly
。因此,您可以在最终的课程路径中使用spring-tx-4.3.11.RELEASE
或spring-context-support-4.3.11.RELEASE
或...
要解决此问题,请确保在类路径中没有版本低于5.0.0
的弹簧框架工作包。
某些必须具有5.0.0版本的spring框架组是:
我使用了eclipse pom查看器,您可以使用Dependency Hierarchy
选项卡查看哪些软件包包含spring框架版本。然后你可以排除它们。
例如对于struts,你必须在下面做:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>${struts2.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</exclusion>
</exclusions>
</dependency>
其他框架也可能需要exclusion
,即使是spring security
或spring-ws
答案 3 :(得分:0)
你的问题在这里
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.3.Final</version>
</dependency>
你正在使用Spring 5,因此你应该将你的休眠更新到版本5,我使用休眠5.0.0.Final
。
答案 4 :(得分:0)
如果您在使用时遇到此错误
<dependency>
<groupId>org.springframework.security.extensions</groupId>
<artifactId>spring-security-saml2-core</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
并升级到Spring Framework 5:升级到版本 1.0.3-RELEASE !
有关详细信息,请参见https://github.com/spring-projects/spring-security-saml/issues/211。