org.springframework.beans.factory.BeanCreationException:创建名称为“ undertowServletWebServerFactory”的bean时出错

时间:2019-10-25 07:48:21

标签: spring-boot jboss migration wildfly web-deployment

我正在从事从Spring到SpringBoot的迁移项目,并且我们还将Web应用程序服务器更改为Redhat Enterprise App服务器。目前,在安装EAP的计算机上进行所有更改之后,我正在尝试运行项目。

我试图在pom.xml中查找并删除重复的声明,从pom文件中删除了Tomcat的所有默认依赖项,但仍然遇到相同的问题。请注意,SpringBootServletInitializer已在主类中进行了扩展,并且configure方法已被覆盖,不确定是否与此相关。

WFLYCTL0186:服务未能启动:service jboss.deployment.unit。“ servicename.war” .undertow-deployment:java.lang.RuntimeException:org.springframework.beans.factory.BeanCreationException:创建名称为'的bean时出错在类路径资源[org / springframework / boot / autoconfigure / web / servlet / ServletWebServerFactoryConfiguration $ EmbeddedUndertow.class]中定义的undertowServletWebServerFactory:Bean初始化失败;嵌套异常是java.lang.LinkageError:违反加载程序约束:解析字段“ MAX_HEADER_SIZE”时,引用类io / undertow / UndertowOptions的类加载器(org / jboss / modules / ModuleClassLoader的实例)和类加载器(实例字段的解析类型org / xnio / Option的org / jboss / modules / ModuleClassLoader属性)具有该类型的不同Class对象

at org.wildfly.extension.undertow.deployment.UndertowDeploymentService $ 1.run(UndertowDeploymentService.java:81)         在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)         在java.util.concurrent.FutureTask.run(FutureTask.java:266)         在org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)         在org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)         在org.jboss.threads.EnhancedQueueExecutor $ ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)         在org.jboss.threads.EnhancedQueueExecutor $ ThreadBody.run(EnhancedQueueExecutor.java:1378)         在java.lang.Thread.run(Thread.java:748)         在org.jboss.threads.JBossThread.run(JBossThread.java:485)

由以下原因引起:java.lang.RuntimeException:org.springframework.beans.factory.BeanCreationException:创建类路径资源[org / springframework / boot / autoconfigure / web / servlet / ServletWebServerFactoryConfiguration $中定义的名称为'undertowServletWebServerFactory'的bean时出错[EmbeddedUndertow.class]:Bean初始化失败;嵌套异常是java.lang.LinkageError:违反加载程序约束:解析字段“ MAX_HEADER_SIZE”时,引用类io / undertow / UndertowOptions的类加载器(org / jboss / modules / ModuleClassLoader的实例)和类加载器(实例字段的解析类型org / xnio / Option的org / jboss / modules / ModuleClassLoader属性)具有该类型的不同Class对象         在io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)         在org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)         在org.wildfly.extension.undertow.deployment.UndertowDeploymentService $ 1.run(UndertowDeploymentService.java:78)         ...另外8个

由于提到的异常,我无法在JBoss EAP 7.2.0.GA(WildFly Core 6.0.11.Final-redhat-00001)中部署项目。

1 个答案:

答案 0 :(得分:0)

我有同样的问题。 我解决了它,声明了所提供的依赖项spring-boot-starter-undertow的范围。

旧pom.xml

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
    </dependency>

新的pom.xml

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
        <scope>provided</scope>
    </dependency>