为什么Infinispan在Spring Boot / Java 11上出现NoClassDefFoundError失败?

问题描述 投票:3回答:3

我正在尝试在Java 11上使用infinispan-spring-boot-starter,但是当App在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

我的设置:

  • ubuntu 16.04
  • maven 3.6
  • openjdk 11.0.1

在这里你可以找到一个小的演示项目来显示问题:https://github.com/ben-schroeder/infinispan-ncdfe。请运行它

mvn clean install
java -jar target/demo-0.0.1-SNAPSHOT.jar

感谢您对此问题的任何帮助。这是一个错误还是我错过了什么?

spring-boot infinispan java-11
3个回答
5
投票

谢谢你的指点。我们正在调查spring-boot团队的问题。这是我们打开的Spring-Boot问题

https://github.com/spring-projects/spring-boot/issues/15981

[更新]今天发布的Spring-Boot 2.1.4.RELEASE(04-04-2019)纠正了这个问题。请查看发行说明,错误修复部分

https://github.com/spring-projects/spring-boot/releases/tag/v2.1.4.RELEASE


1
投票

我也注意到了这一点。直到有解决方案,9.4.3.Final工作正常。问题是从9.4.4开始。


-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'
© www.soinside.com 2019 - 2024. All rights reserved.