1

经过长时间的搜索,我的案子没有得到答复,我来了。尝试将“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>

我搜索了很多,但没有找到解决我的问题。

4

5 回答 5

1

如果您在使用时遇到此错误

    <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

于 2020-02-26T11:48:41.083 回答
0

我遇到了这个问题,我试图将war文件部署到tomcat 8,在我的情况下,我使用的一个库依赖于spring-context,它引入了4.3.3版,在这个版本中有类

public class ContextBeanFactoryReference implements BeanFactoryReference

正如您发现的那样BeanFactoryReference,版本 5 中不存在。

我可以看到您已经获得了 spring-context 版本 5,只需仔细检查您的依赖项并确保只有 spring 版本 5 而没有其他版本。

如果有其他一些图书馆带来的任何其他人,你可以通过使用排除它们

<exclusions>
 <exclusion>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
 </exclusion>
</exclusions>

这解决了我的问题,感觉你的问题类似。

于 2017-10-17T09:11:34.673 回答
0

你的问题在这里

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.6.3.Final</version>
</dependency>

您使用的是 Spring 5,因此您也应该将 hibernate 更新到版本 5,我使用 hibernate 5.0.0.Final

于 2017-12-04T02:24:11.270 回答
0

您可能indirectly在项目中添加了一些弹簧框架工程库。因此,您的最终课程路径中可能有例如spring-tx-4.3.11.RELEASEor spring-context-support-4.3.11.RELEASEor ... 。

要解决它,请确保没有版本低于5.0.0您的类路径的弹簧框架工作包。

一些必须有 5.0.0 版本的 spring 框架组是:

  1. 弹簧上下文
  2. 弹簧测试
  3. 弹簧芯
  4. 春豆
  5. 弹簧网
  6. spring-webmvc
  7. 春牛
  8. 弹簧-jms
  9. spring-jdbc

我用的是eclipse pom viewer,你可以通过Dependency Hierarchytab查看哪些包包含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 securityspring-ws

于 2017-10-17T12:12:45.020 回答
0

您可能对这里的 spring-core 依赖项有疑问。除非您的类路径中有 spring-core,否则我建议将依赖范围更改为默认(或 jar)而不是运行时。

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.0.RELEASE</version>
</dependency>
于 2017-10-06T18:44:43.253 回答