0

我有一个配置了 infinispan 的 Maven 项目:

<dependency>
    <groupId>org.infinispan</groupId>
    <artifactId>infinispan-hibernate-cache-v53</artifactId>
    <version>${version.infinispan}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.infinispan</groupId>
    <artifactId>infinispan-core</artifactId>
    <version>${version.infinispan}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.infinispan</groupId>
    <artifactId>infinispan-hibernate-cache-commons</artifactId>
    <version>${version.infinispan}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.marshalling</groupId>
    <artifactId>jboss-marshalling</artifactId>
    <version>2.0.9.Final</version>
    <scope>test</scope>
</dependency>

version.infinispan 是 9.4.16.Final,这与 Wildfly 18 相同,我正在使用的 AS。

我创建了一个单元测试:

@Test
void expired_object() throws Exception {
    final GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
            .defaultCacheName("local")
            .build();
    final Configuration configuration = new ConfigurationBuilder()
            .memory()
            .expiration()
            .lifespan(-1)
            .maxIdle(4000)
            .build();
    final EmbeddedCacheManager manager = new DefaultCacheManager(globalConfig, configuration, false);
    ...

当尝试实例化 EmbeddedCacheManager 时,它在最后一行失败。错误日志是:

    org.infinispan.commons.CacheException: Unable to construct a GlobalComponentRegistry!

    at org.infinispan.factories.GlobalComponentRegistry.<init>(GlobalComponentRegistry.java:164)
    at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:257)
    at it.infocert.ecommerce.checkout.infinispan.CacheTest.expired_object(CacheTest.java:57)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:117)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:184)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:180)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:127)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
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:147)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.getComponent0(BasicComponentRegistryImpl.java:108)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.getComponent(BasicComponentRegistryImpl.java:73)
    at org.infinispan.factories.impl.BasicComponentRegistry.getComponent(BasicComponentRegistry.java:75)
    at org.infinispan.factories.GlobalComponentRegistry.<init>(GlobalComponentRegistry.java:158)
    ... 53 more
Caused by: java.lang.ExceptionInInitializerError
    at org.infinispan.factories.EncoderRegistryFactory.construct(EncoderRegistryFactory.java:42)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.instantiateWrapper(BasicComponentRegistryImpl.java:143)
    ... 57 more
Caused by: java.lang.IllegalStateException: River marshaller factory not found.  Verify that the JBoss Marshalling River jar archive is in the classpath.
    at org.infinispan.commons.marshall.jboss.JBossMarshallerFactory.<init>(JBossMarshallerFactory.java:31)
    at org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller.<clinit>(AbstractJBossMarshaller.java:43)
    ... 59 more

哪里错了?

4

1 回答 1

2

尝试添加jboss-marshalling-river

<dependency>
    <groupId>org.jboss.marshalling</groupId>
    <artifactId>jboss-marshalling-river</artifactId>
    <version>2.0.9.Final</version>
    <scope>test</scope>
</dependency>
于 2020-07-06T14:39:16.160 回答