我正在尝试在Java 11上使用infinispan-spring-boot-starter,但是当该应用程序在jar中启动时,它会失败,并出现NoClassDefFoundError。
如果我在Java 8上运行,效果很好。
在Java 11上运行,效果也很好。 mvn spring-boot:run
,但如果执行
,则失败 java -jar target/demo-0.0.1-SNAPSHOT.jar
具有以下例外:
Caused by: org.infinispan.commons.CacheConfigurationException: Failed to construct component org.infinispan.marshall.core.EncoderRegistry, path null
at org.infinispan.factories.impl.BasicComponentRegistryImpl.instantiateWrapper(BasicComponentRegistryImpl.java:141) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
at org.infinispan.factories.impl.BasicComponentRegistryImpl.getComponent0(BasicComponentRegistryImpl.java:107) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
at org.infinispan.factories.impl.BasicComponentRegistryImpl.getComponent(BasicComponentRegistryImpl.java:73) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
at org.infinispan.factories.impl.BasicComponentRegistry.getComponent(BasicComponentRegistry.java:75) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
at org.infinispan.factories.GlobalComponentRegistry.<init>(GlobalComponentRegistry.java:158) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
... 56 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/infinispan/commons/util/FastCopyHashMap$Values (wrong name: org/infinispan/commons/dataconversion/BinaryEncoder)
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[na:na]
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[na:na]
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550) ~[na:na]
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458) ~[na:na]
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[na:na]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
at org.infinispan.factories.EncoderRegistryFactory.construct(EncoderRegistryFactory.java:48) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
at org.infinispan.factories.impl.BasicComponentRegistryImpl.instantiateWrapper(BasicComponentRegistryImpl.java:137) ~[infinispan-core-9.4.5.Final.jar!/:9.4.5.Final]
... 60 common frames omitted
我的设置:
在这里您可以找到一个演示项目来演示问题:https://github.com/ben-schroeder/infinispan-ncdfe。请使用
mvn clean install
java -jar target/demo-0.0.1-SNAPSHOT.jar
感谢您对问题的任何帮助。是错误还是我错过了什么?
答案 0 :(得分:5)
感谢您指出这一点。我们正在与Spring-boot团队一起调查问题。 这是我们打开的Spring-Boot问题
https://github.com/spring-projects/spring-boot/issues/15981
[更新] 今天(04-04-2019)发布的Spring-Boot 2.1.4.RELEASE更正了此问题。请查看发行说明,错误修复部分
https://github.com/spring-projects/spring-boot/releases/tag/v2.1.4.RELEASE
答案 1 :(得分:1)
我也注意到了这一点。在找到解决方案之前,9.4.3.Final可以正常工作。问题是从9.4.4开始。
答案 2 :(得分:-1)
9.4.5和9.4.4也会导致此问题。
对于在gradle构建环境中遇到相同问题的其他人,请将infinispan瞬态依赖项从引入它们的依赖项中排除,并明确引入9.4.3版本:
compile (group: "the.lib.that.pulls.in", name: "the", version: transients) {
exclude group: 'org.infinispan', module: 'infinispan-core'
exclude group: 'org.infinispan', module: 'infinispan-client-hotrod'
exclude group: 'org.infinispan', module: 'infinispan-query-dsl'
exclude group: 'org.infinispan', module: 'infinispan-commons'
}
implementation group: 'org.infinispan', name: 'infinispan-core', version: '9.4.3.Final'
implementation group: 'org.infinispan', name: 'infinispan-client-hotrod', version: '9.4.3.Final'
implementation group: 'org.infinispan', name: 'infinispan-query-dsl', version: '9.4.3.Final'
implementation group: 'org.infinispan', name: 'infinispan-commons', version: '9.4.3.Final'