更新到 Spring 5.1 - java.lang.NoClassDefFoundError: org/springframework/http/server/reactive/ServletSer

Posted

技术标签:

【中文标题】更新到 Spring 5.1 - java.lang.NoClassDefFoundError: org/springframework/http/server/reactive/ServletServerHttpResponse$ResponseBodyProcessor【英文标题】:Update to Spring 5.1 - java.lang.NoClassDefFoundError: org/springframework/http/server/reactive/ServletServerHttpResponse$ResponseBodyProcessor 【发布时间】:2019-03-13 13:35:18 【问题描述】:

在尝试从 4.3 更新到 Spring 5.1 时,我在部署时收到以下堆栈跟踪。服务器是 WildFly 14。运行时是 JDK 11。编译器目标是 1.8。

我尝试清理依赖项,但没有任何帮助。下面是依赖:树输出。

22:23:51,323 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."BDOS-POP.war".component."org.springframework.http.server.reactive.ServletServerHttpResponse$ResponseAsyncListener".WeldInstantiator: org.jboss.msc.service.StartException in service jboss.deployment.unit."BDOS-POP.war".component."org.springframework.http.server.reactive.ServletServerHttpResponse$ResponseAsyncListener".WeldInstantiator: Failed to start service
    at org.jboss.msc@1.4.3.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1728)
    at org.jboss.msc@1.4.3.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
    at org.jboss.threads@2.3.2.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
    at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
    at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1364)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class org.springframework.http.server.reactive.ServletServerHttpResponse$ResponseAsyncListener
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:186)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getEnhancedAnnotatedType(ClassTransformer.java:232)
    at org.jboss.as.weld@14.0.0.Final//org.jboss.as.weld.injection.InjectionTargets.createInjectionTarget(InjectionTargets.java:60)
    at org.jboss.as.weld@14.0.0.Final//org.jboss.as.weld.injection.WeldComponentService.start(WeldComponentService.java:120)
    at org.jboss.msc@1.4.3.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)
    at org.jboss.msc@1.4.3.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)
    ... 6 more
Caused by: java.lang.NoClassDefFoundError: Failed to link org/springframework/http/server/reactive/ServletServerHttpResponse$ResponseBodyProcessor (Module "deployment.BDOS-POP.war" from Service Module Loader): Failed to link org/springframework/http/server/reactive/AbstractListenerWriteProcessor (Module "deployment.BDOS-POP.war" from Service Module Loader): org/reactivestreams/Processor
    at java.base/java.lang.Class.getDeclaringClass0(Native Method)
    at java.base/java.lang.Class.getDeclaringClass(Class.java:1472)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.reflection.Reflections.checkDeclaringClassLoadable(Reflections.java:427)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:83)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:79)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$null$0(ReentrantMapBackedComputingCache.java:55)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.WeakLazyValueHolder$1.computeValue(WeakLazyValueHolder.java:35)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.WeakLazyValueHolder.get(WeakLazyValueHolder.java:53)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getCastValue(ReentrantMapBackedComputingCache.java:78)
    at org.jboss.weld.core@3.0.5.Final//org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:177)
    ... 12 more

mvn 依赖:树看起来像这样:

[INFO] com.company:app:war:1.0-SNAPSHOT
[INFO] +- org.apache.wicket:wicket-core:jar:7.10.0:compile
[INFO] |  +- org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] |  +- org.apache.wicket:wicket-request:jar:7.10.0:compile
[INFO] |  +- org.apache.wicket:wicket-util:jar:7.10.0:compile
[INFO] |  |  \- commons-fileupload:commons-fileupload:jar:1.3.2:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- org.apache.wicket:wicket-extensions:jar:7.10.0:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.25:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.springframework:spring-core:jar:5.1.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-jcl:jar:5.1.0.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:5.1.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-beans:jar:5.1.0.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.1.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.1.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:5.1.0.RELEASE:compile
[INFO] +- org.apache.wicket:wicket-spring:jar:7.10.0:compile
[INFO] |  \- org.apache.wicket:wicket-ioc:jar:7.10.0:compile
[INFO] |     +- cglib:cglib:jar:3.1:compile
[INFO] |     +- javax.inject:javax.inject:jar:1:compile
[INFO] |     \- org.ow2.asm:asm-util:jar:5.0.3:compile
[INFO] |        \- org.ow2.asm:asm-tree:jar:5.0.3:compile
[INFO] |           \- org.ow2.asm:asm:jar:5.0.3:compile
[INFO] +- org.apache.wicket:wicket-devutils:jar:7.10.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:5.1.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-tx:jar:5.1.0.RELEASE:compile
[INFO] +- org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec:jar:1.0.0.Final:compile
[INFO] +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.8:compile
[INFO] +- com.company:wicketWebComponents:jar:2.0.0-SNAPSHOT:compile
[INFO] |  \- org.apache.commons:commons-vfs2:jar:2.1:compile
[INFO] |     \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- com.company.marsz:MailSender:jar:1.8.1:compile
[INFO] |  \- org.apache.commons:commons-email:jar:1.4:compile
[INFO] |     +- com.sun.mail:javax.mail:jar:1.5.2:compile
[INFO] |     \- javax.activation:activation:jar:1.1.1:compile
[INFO] +- net.bull.javamelody:javamelody-core:jar:1.74.0:compile
[INFO] |  \- org.jrobin:jrobin:jar:1.5.9:compile
[INFO] +- com.company.proces:system-parameters:jar:1.8.6-SNAPSHOT:compile
[INFO] |  +- redis.clients:jedis:jar:2.9.0:compile
[INFO] |  |  \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] |  +- org.springframework.data:spring-data-redis:jar:2.1.0.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-keyvalue:jar:2.1.0.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-oxm:jar:5.1.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-context-support:jar:5.1.0.RELEASE:compile
[INFO] |  +- com.company:energetyka-coretypes:jar:1.8.1-umarsz:compile
[INFO] |  \- com.company:ucore:jar:1.8.6-SNAPSHOT:compile
[INFO] +- com.company:sso-service:jar:1.8.0:compile
[INFO] |  \- org.jasig.cas.client:cas-client-core:jar:3.4.1:compile
[INFO] +- com.company:appBackend:jar:1.0-SNAPSHOT:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.1.0.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.1.0.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.1.0.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjrt:jar:1.9.1:compile
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] |  +- com.sun.xml.bind:jaxb-core:jar:2.3.0:compile
[INFO] |  +- com.sun.xml.bind:jaxb-impl:jar:2.3.0:compile
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.1:compile
[INFO] |  \- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.5:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.5:compile
[INFO] +- com.company:notification-api:jar:0.0.1-SNAPSHOT:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.6.2:compile
[INFO] |  \- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- com.company:c-components:jar:1.1.1-SNAPSHOT:compile
[INFO] +- com.company.marsz:wicketWebComponents:jar:1.8-SNAPSHOT:compile
[INFO] +- com.company.marsz:ExcelReports:jar:1.8.1:compile
[INFO] |  +- com.company.marsz:statistics:jar:1.8.1:compile
[INFO] |  +- commons-io:commons-io:jar:2.6:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  +- org.apache.poi:poi:jar:4.0.0:compile
[INFO] |  +- org.apache.poi:poi-ooxml:jar:4.0.0:compile
[INFO] |  |  +- org.apache.poi:poi-ooxml-schemas:jar:4.0.0:compile
[INFO] |  |  |  \- org.apache.xmlbeans:xmlbeans:jar:3.0.1:compile
[INFO] |  |  +- org.apache.commons:commons-compress:jar:1.18:compile
[INFO] |  |  \- com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] |  \- xerces:xercesImpl:jar:2.12.0:compile
[INFO] |     \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.3.6.Final:provided
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:provided
[INFO] |  +- org.javassist:javassist:jar:3.23.1-GA:provided
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.8.17:provided
[INFO] |  +- antlr:antlr:jar:2.7.7:provided
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:provided
[INFO] |  +- org.jboss:jandex:jar:2.0.5.Final:provided
[INFO] |  +- com.fasterxml:classmate:jar:1.3.4:provided
[INFO] |  +- javax.activation:javax.activation-api:jar:1.2.0:provided
[INFO] |  +- dom4j:dom4j:jar:1.6.1:provided
[INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:provided
[INFO] \- com.company:multitenancy:jar:1.0.0-SNAPSHOT:compile

【问题讨论】:

【参考方案1】:

我在 wildfly 论坛上找到了帮助:https://developer.jboss.org/thread/276373?start=15&tstart=0

添加此依赖项后,它可以工作:

<dependency>
   <groupId>org.reactivestreams</groupId>
   <artifactId>reactive-streams</artifactId>
   <version>1.0.1</version>
</dependency>

【讨论】:

很好奇,这对我有用。但是我们公司的其他项目(所以在相同的应用服务器上)不需要这个。 它也适用于我,使用 Wildfly 17 和 Spring Web MVC 5.1.9 但如果我不制作响应式应用程序,为什么我必须包含此依赖项?

以上是关于更新到 Spring 5.1 - java.lang.NoClassDefFoundError: org/springframework/http/server/reactive/ServletSer的主要内容,如果未能解决你的问题,请参考以下文章

将 Xcode 从 5.0 更新到 5.1 后生成错误

Spring学习笔记(持续更新……)

在 CentOS 6.2 中将 MySQL 版本从 5.1 更新到 5.5

spring in action 5.1 小结

未初始化的常量 Faker::Date 更新到 rails 5.1

从 Laravel 5.1 到 5.2 的更新已停止 PHPUnit 工作