在 Wildfly 上运行时 Spring Boot 应用程序问题(bean 创建错误)
Posted
技术标签:
【中文标题】在 Wildfly 上运行时 Spring Boot 应用程序问题(bean 创建错误)【英文标题】:Spring Boot application issue(bean creation error) when running on wildfly 【发布时间】:2020-05-18 04:26:41 【问题描述】:我对开发 Java 应用程序比较陌生,我正在尝试在 Wildfly 上部署一个简单的应用程序,并且我收到了 org.springframework.beans.factory.BeanCreationException。我不明白出了什么问题。当我使用 Tomcat 运行相同的应用程序时,我没有收到任何错误。
这是日志
16:47:10,932 INFO [org.jboss.modules] (main) JBoss Modules version 1.8.5.Final
16:47:12,354 INFO [org.jboss.msc] (main) JBoss MSC version 1.4.2.Final
16:47:12,452 INFO [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final
16:47:12,868 INFO [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 13.0.0.Final (WildFly Core 5.0.0.Final) starting
16:47:15,882 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
16:47:15,944 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 8) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
16:47:15,951 INFO [org.wildfly.security] (ServerService Thread Pool -- 19) ELY00001: WildFly Elytron version 1.3.3.Final
16:47:16,060 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found supplier-0.0.1-SNAPSHOT.war in deployment directory. To trigger deployment create a file called supplier-0.0.1-SNAPSHOT.war.dodeploy
16:47:16,140 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
16:47:16,170 INFO [org.xnio] (MSC service thread 1-6) XNIO version 3.6.3.Final
16:47:16,183 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.6.3.Final
16:47:16,384 INFO [org.jboss.as.security] (ServerService Thread Pool -- 60) WFLYSEC0002: Activating Security Subsystem
16:47:16,375 INFO [org.jboss.as.jaxrs] (ServerService Thread Pool -- 47) WFLYRS0016: RESTEasy version 3.5.1.Final
16:47:16,415 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 62) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
16:47:16,428 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 45) WFLYCLINF0001: Activating Infinispan subsystem.
16:47:16,436 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 54) WFLYNAM0001: Activating Naming Subsystem
16:47:16,471 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 64) WFLYWS0002: Activating WebServices Extension
16:47:16,514 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 52) WFLYJSF0007: Activated the following JSF Implementations: [main]
16:47:16,535 INFO [org.jboss.as.security] (MSC service thread 1-8) WFLYSEC0001: Current PicketBox version=5.0.2.Final
16:47:16,559 INFO [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.9.Final)
16:47:16,546 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 38) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
16:47:16,618 INFO [org.jboss.as.ee] (ServerService Thread Pool -- 41) WFLYEE0119: The system property 'ee8.preview.mode' is NOT set to 'true'. For provided EE 8 APIs where the EE 8 version of the API differs from what is supported in EE 7, the EE 7 variant of the API will be used. Support for this setting will be removed once all EE 8 APIs are provided and certified.
16:47:16,634 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0003: Undertow 2.0.9.Final starting
16:47:16,648 INFO [org.jboss.as.naming] (MSC service thread 1-1) WFLYNAM0003: Starting Naming Service
16:47:16,675 INFO [org.jboss.as.mail.extension] (MSC service thread 1-5) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
16:47:16,681 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = h2
16:47:16,952 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 63) WFLYUT0014: Creating file handler for path 'C:\Users\abc\wildfly-13.0.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
16:47:17,722 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 46) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
16:47:18,007 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\abc\wildfly-13.0.0.Final\standalone\deployments
16:47:18,035 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "supplier-0.0.1-SNAPSHOT.war" (runtime-name: "supplier-0.0.1-SNAPSHOT.war")
16:47:40,785 INFO [stdout] (ServerService Thread Pool -- 86)
16:47:40,786 INFO [stdout] (ServerService Thread Pool -- 86) . ____ _ __ _ _
16:47:40,786 INFO [stdout] (ServerService Thread Pool -- 86) /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
16:47:40,786 INFO [stdout] (ServerService Thread Pool -- 86) ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
16:47:40,786 INFO [stdout] (ServerService Thread Pool -- 86) \\/ ___)| |_)| | | | | || (_| | ) ) ) )
16:47:40,786 INFO [stdout] (ServerService Thread Pool -- 86) ' |____| .__|_| |_|_| |_\__, | / / / /
16:47:40,787 INFO [stdout] (ServerService Thread Pool -- 86) =========|_|==============|___/=/_/_/_/
16:47:40,787 INFO [stdout] (ServerService Thread Pool -- 86) :: Spring Boot :: (v2.2.2.RELEASE)
16:47:40,789 INFO [stdout] (ServerService Thread Pool -- 86)
16:47:40,975 INFO [com.xxx.edi.supplier.ServletInitializer] (ServerService Thread Pool -- 86) Starting ServletInitializer on OLA-3XQ41Z2 with PID 22016 (C:\Users\abc\wildfly-13.0.0.Final\standalone\deployments\supplier-0.0.1-SNAPSHOT.war\WEB-INF\classes started by abc in C:\Users\abc\wildfly-13.0.0.Final\bin)
16:47:40,977 INFO [com.xxx.edi.supplier.ServletInitializer] (ServerService Thread Pool -- 86) No active profile set, falling back to default profiles: default
16:47:42,843 INFO [io.undertow.servlet] (ServerService Thread Pool -- 86) Initializing Spring embedded WebApplicationContext
16:47:42,843 INFO [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 86) Root WebApplicationContext: initialization completed in 1799 ms
16:47:43,309 WARN [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext] (ServerService Thread Pool -- 86) 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
16:47:43,356 INFO [org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener] (ServerService Thread Pool -- 86)
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
16:47:43,358 ERROR [org.springframework.boot.SpringApplication] (ServerService Thread Pool -- 86) 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:603)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:152)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:132)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:92)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:204)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1514)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1514)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1514)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1514)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:251)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:485)
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:79)
at org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer.customize(UndertowWebServerFactoryCustomizer.java:57)
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:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
... 36 more
16:47:43,377 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 86) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./supplier: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./supplier: 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:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:485)
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:253)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
... 8 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
org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1514)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:251)
... 10 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:79)
at org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer.customize(UndertowWebServerFactoryCustomizer.java:57)
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:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
... 36 more
16:47:43,393 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "supplier-0.0.1-SNAPSHOT.war")]) - failure description:
"WFLYCTL0080: Failed services" => "jboss.undertow.deployment.default-server.default-host./supplier" => "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",
"WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." =>
"Services that were unable to start:" => ["jboss.deployment.unit.\"supplier-0.0.1-SNAPSHOT.war\".deploymentCompleteService"],
"Services that may be the cause:" => [
"jboss.clustering.web.route.default-server",
"jboss.iiop-openjdk.poa-service.rootpoa",
"jboss.txn.service.remote",
"jboss.xts.handlers",
下面是 POM
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.edi</groupId>
<artifactId>supplier</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Supplier Web</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
</parent>
<dependencies>
<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>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<finalName>supplier</finalName>
</build>
</project>
控制器类
package com.xxx.edi.supplier.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class AppController
@RequestMapping(value = "/test")
public String test() throws Exception
System.out.println("In the Controller");
return "test";
这是否与版本冲突有关?我似乎无法理解。感谢任何输入。
提前致谢!
【问题讨论】:
【参考方案1】:Wildfly 使用 Undertow 作为其 Servlet 容器,并且您依赖于 Spring Boot 的 Undertow 启动器。因此,有两种不同版本的 Undertow 类可用。正如您所怀疑的,这两个版本存在冲突并导致失败。
如果您只是将应用程序部署到 Wildfly,则可以完全删除对 spring-boot-starter-undertow
的依赖。如果您希望能够使用嵌入式 Undertow 在 Wildfly 之外运行您的应用,您应该将 spring-boot-starter-undertow
的依赖标记为 <scope>provided</scope>
。
【讨论】:
谢谢,昨晚我添加了以上是关于在 Wildfly 上运行时 Spring Boot 应用程序问题(bean 创建错误)的主要内容,如果未能解决你的问题,请参考以下文章
Wildfly 8.x 上带有 Spring Boot 的 Restful 服务
wildfly 12 和 spring java 配置,不工作,403 错误
Spring Boot 应用程序未部署在 Wildfly 上
Spring Boot 2 重新部署到 Wildfly 10 后无法刷新 JMS 连接