【问题标题】:java.lang.LinkageError: loader constraint violation: when resolving field "MAX_HEADER_SIZE"java.lang.LinkageError:加载程序约束冲突:解析字段“MAX_HEADER_SIZE”时
【发布时间】:2022-08-17 23:53:51
【问题描述】:

当我尝试在Wildfly 10.1.0.Final 上部署我的war 时收到此错误(我无法更改wildfly 版本)

18:53:58,467 WARN  [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext] (ServerService Thread Pool -- 78) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
18:53:58,493 INFO  [org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener] (ServerService Thread Pool -- 78)

Error starting ApplicationContext. To display the conditions report re-run your application with \'debug\' enabled.
18:53:58,536 ERROR [org.springframework.boot.SpringApplication] (ServerService Thread Pool -- 78) Application run failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
        at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186)
        at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:171)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:234)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
        at org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer.customize(UndertowWebServerFactoryCustomizer.java:81)
        at org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer.customize(UndertowWebServerFactoryCustomizer.java:59)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.lambda$postProcessBeforeInitialization$0(WebServerFactoryCustomizerBeanPostProcessor.java:72)
        at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$null$0(LambdaSafe.java:287)
        at org.springframework.boot.util.LambdaSafe$LambdaSafeCallback.invoke(LambdaSafe.java:159)
        at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$invoke$1(LambdaSafe.java:286)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1082)
        at org.springframework.boot.util.LambdaSafe$Callbacks.invoke(LambdaSafe.java:286)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:72)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
        ... 34 more

18:53:58,543 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 78) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host.\"/custom-crm-ticket-0.0.1-SNAPSHOT\": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.\"/custom-crm-ticket-0.0.1-SNAPSHOT\": java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:236)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
        ... 6 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
        at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186)
        at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:171)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:234)
        ... 8 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
        at org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer.customize(UndertowWebServerFactoryCustomizer.java:81)
        at org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer.customize(UndertowWebServerFactoryCustomizer.java:59)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.lambda$postProcessBeforeInitialization$0(WebServerFactoryCustomizerBeanPostProcessor.java:72)
        at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$null$0(LambdaSafe.java:287)
        at org.springframework.boot.util.LambdaSafe$LambdaSafeCallback.invoke(LambdaSafe.java:159)
        at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$invoke$1(LambdaSafe.java:286)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1082)
        at org.springframework.boot.util.LambdaSafe$Callbacks.invoke(LambdaSafe.java:286)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:72)
        at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
        ... 34 more

18:53:58,560 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation (\"deploy\") failed - address: ([(\"deployment\" => \"custom-crm-ticket-0.0.1-SNAPSHOT.war\")]) - failure description: {
    \"WFLYCTL0080: Failed services\" => {\"jboss.undertow.deployment.default-server.default-host.\\\"/custom-crm-ticket-0.0.1-SNAPSHOT\\\"\" => \"org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.\\\"/custom-crm-ticket-0.0.1-SNAPSHOT\\\": java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \\\"MAX_HEADER_SIZE\\\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
    Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \\\"MAX_HEADER_SIZE\\\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \\\"MAX_HEADER_SIZE\\\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type
    Caused by: java.lang.LinkageError: loader constraint violation: when resolving field \\\"MAX_HEADER_SIZE\\\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type\"},
    \"WFLYCTL0412: Required services that are not installed:\" => [\"jboss.undertow.deployment.default-server.default-host.\\\"/custom-crm-ticket-0.0.1-SNAPSHOT\\\"\"],
    \"WFLYCTL0180: Services with missing/unavailable dependencies\" => undefined
}
18:53:58,665 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed \"custom-crm-ticket-0.0.1-SNAPSHOT.war\" (runtime-name : \"custom-crm-ticket-0.0.1-SNAPSHOT.war\")
18:53:58,666 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 1) WFLYCTL0183: Service status report
WFLYCTL0186:   Services which failed to start:      service jboss.undertow.deployment.default-server.default-host.\"/custom-crm-ticket-0.0.1-SNAPSHOT\": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.\"/custom-crm-ticket-0.0.1-SNAPSHOT\": java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'undertowServletWebServerFactory\' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field \"MAX_HEADER_SIZE\" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the referring class, io/undertow/UndertowOptions, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the field\'s resolved type, org/xnio/Option, have different Class objects for that type

这是我的pom

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.hpe.du</groupId>
    <artifactId>custom-crm-ticket</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>custom-crm-ticket</name>
    <description>custom ticketing</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.24</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20220320</version>
        </dependency>
        <dependency>
            <groupId>javax.jms</groupId>
            <artifactId>javax.jms-api</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>javax.jms</groupId>
            <artifactId>jms</artifactId>
            <version>1.1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-jms-client-bom</artifactId>
            <version>10.1.0.Final</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-naming-client</artifactId>
            <version>1.0.15.Final</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

我还尝试将pom 更改如下

<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-jms-client-bom</artifactId>
    <version>10.1.0.Final</version>
    <type>pom</type>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-naming-client</artifactId>
    <version>1.0.15.Final</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

错误消失了,wardeployed,但是当我调用 REST 时,我收到了错误

19:02:49,017 ERROR [stderr] (Thread-133) Exception in thread \"Thread-133\" java.lang.NoClassDefFoundError: org/xnio/Options
19:02:49,021 ERROR [stderr] (Thread-133)        at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:92)
19:02:49,022 ERROR [stderr] (Thread-133)        at java.lang.Class.forName0(Native Method)
19:02:49,025 ERROR [stderr] (Thread-133)        at java.lang.Class.forName(Class.java:348)
19:02:49,027 ERROR [stderr] (Thread-133)        at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:113)
19:02:49,032 ERROR [stderr] (Thread-133)        at org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
19:02:49,034 ERROR [stderr] (Thread-133)        at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
19:02:49,046 ERROR [stderr] (Thread-133)        at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:89)
19:02:49,049 ERROR [stderr] (Thread-133)        at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)
19:02:49,060 ERROR [stderr] (Thread-133)        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
19:02:49,063 ERROR [stderr] (Thread-133)        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
19:02:49,064 ERROR [stderr] (Thread-133)        at javax.naming.InitialContext.init(InitialContext.java:244)
19:02:49,065 ERROR [stderr] (Thread-133)        at javax.naming.InitialContext.<init>(InitialContext.java:216)
19:02:49,066 ERROR [stderr] (Thread-133)        at com.hpe.du.customcrmticket.JMSUtils.customTTJMSCommunication.elaborateRequest(customTTJMSCommunication.java:100)
19:02:49,066 ERROR [stderr] (Thread-133)        at com.hpe.du.customcrmticket.customCrmTicketController.lambda$createTT$0(customCrmTicketController.java:36)
19:02:49,067 ERROR [stderr] (Thread-133)        at java.lang.Thread.run(Thread.java:748)
19:02:49,072 ERROR [stderr] (Thread-133) Caused by: java.lang.ClassNotFoundException: org.xnio.Options from [Module \"deployment.custom-crm-ticket-0.0.1-SNAPSHOT.war:main\" from Service Module Loader]
19:02:49,093 ERROR [stderr] (Thread-133)        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
19:02:49,094 ERROR [stderr] (Thread-133)        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
19:02:49,095 ERROR [stderr] (Thread-133)        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
19:02:49,096 ERROR [stderr] (Thread-133)        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
19:02:49,097 ERROR [stderr] (Thread-133)        ... 15 more

我不明白为什么没有排除会有这个错误,但是排除它需要依赖

    标签: java spring-boot pom.xml


    【解决方案1】:

    我以这种方式解决了问题 在 pom.xml 我排除了 xnio-api (如问题所示)

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-jms-client-bom</artifactId>
        <version>10.1.0.Final</version>
        <type>pom</type>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.xnio</groupId>
                <artifactId>xnio-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-naming-client</artifactId>
        <version>1.0.15.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.jboss.xnio</groupId>
                <artifactId>xnio-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    

    然后我在webapp/WEB-INF文件夹下创建了jboss-deployment-structure.xml,里面有这个内容

    <jboss-deployment-structure>
        <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
        <deployment>
            <dependencies>
                <module name="org.jboss.xnio" />
            </dependencies>
        </deployment>
    
    </jboss-deployment-structure>
    

    现在WAR 部署没有问题

    希望这有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-30
      • 1970-01-01
      • 2014-08-16
      • 2018-04-04
      • 2011-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多