1

我正在尝试在 wildfly 18 上配置缓存-但是我面临的问题是我认为它与 jgroups 中的依赖项版本或删除的方法以及 infinispan 模块有关。错误

Caused by: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport

并且

Caused by: java.lang.NoSuchMethodError: org.jgroups.JChannel.<init>(Ljava/net/URL;)V

WildFly 18.0.1 包含以下 Infinispan 罐子:

./modules/system/layers/base/org/infinispan/commons/main/infinispan-commons-9.4.16.Final.jar
./modules/system/layers/base/org/infinispan/main/infinispan-core-9.4.16.Final.jar

JGroups 也有:

./modules/system/layers/base/org/jgroups/main/jgroups-4.1.4.Final.jar

似乎 Infinispan 9.4.16 依赖于不同版本的 JGroups:

<version.jgroups>4.0.20.Final</version.jgroups>

请参阅链接 https://github.com/infinispan/infinispan/blob/9.4.16.Final/build-configuration/pom.xml#L180

结果,当我尝试启动服务器时,出现以下错误

2020-03-29 18:38:25,808 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 80) MSC000001: Failed to start service jboss.deployment.unit."-frontend-war.war".component.CacheContainerBean.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."-frontend-war.war".component.CacheContainerBean.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57)
    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:1982)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
    at java.lang.Thread.run(Thread.java:748)
    at org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
    at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
    at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:127)
    at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:141)
    at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
    ... 8 more
Caused by: javax.ejb.EJBException: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:246)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:388)
    at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:68)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ejb3.component.singleton.StartupCountDownInterceptor.processInvocation(StartupCountDownInterceptor.java:25)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
    at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
    ... 13 more
Caused by: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    at org.infinispan.manager.DefaultCacheManager.internalStart(DefaultCacheManager.java:712)
    at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:677)
    at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:269)
    at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:227)
    at xa.comp.util.CacheContainerBean.container(CacheContainerBean.java:50)
    at xa.comp.util.CacheContainerBean.generateCache(CacheContainerBean.java:93)
    at xa.comp.util.CacheContainerBean.init(CacheContainerBean.java:64)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
    at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.delegateInterception(Jsr299BindingsInterceptor.java:79)
    at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:126)
    at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:112)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
    at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:81)
    at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.weld.interceptors.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:111)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:237)
    ... 28 more
Caused by: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    at org.infinispan.commons.util.SecurityActions.lambda$invokeAccessibly$0(SecurityActions.java:83)
    at org.infinispan.commons.util.SecurityActions.doPrivileged(SecurityActions.java:71)
    at org.infinispan.commons.util.SecurityActions.invokeAccessibly(SecurityActions.java:76)
    at org.infinispan.commons.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:181)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:534)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:723)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.startDependencies(BasicComponentRegistryImpl.java:565)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:520)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:723)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.startDependencies(BasicComponentRegistryImpl.java:576)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:520)
    at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:723)
    at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:428)
    at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:325)
    at org.infinispan.manager.DefaultCacheManager.internalStart(DefaultCacheManager.java:709)
    ... 60 more
Caused by: java.lang.NoSuchMethodError: org.jgroups.JChannel.<init>(Ljava/net/URL;)V
    at org.infinispan.remoting.transport.jgroups.JGroupsTransport.buildChannel(JGroupsTransport.java:590)
    at org.infinispan.remoting.transport.jgroups.JGroupsTransport.initChannel(JGroupsTransport.java:403)
    at org.infinispan.remoting.transport.jgroups.JGroupsTransport.start(JGroupsTransport.java:387)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.infinispan.commons.util.SecurityActions.lambda$invokeAccessibly$0(SecurityActions.java:79)
    ... 74 more

2020-03-29 18:38:25,852 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "-frontend-war.war")) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"-frontend-war.war\".component.CacheContainerBean.START" => "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    Caused by: javax.ejb.EJBException: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    Caused by: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    Caused by: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    Caused by: java.lang.NoSuchMethodError: org.jgroups.JChannel.<init>(Ljava/net/URL;)V"}}
2020-03-29 18:38:25,853 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "-frontend-war.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"-frontend-war.war\".component.CacheContainerBean.START" => "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
    Caused by: javax.ejb.EJBException: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    Caused by: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    Caused by: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.remoting.transport.jgroups.JGroupsTransport.start() on object of type JGroupsTransport
    Caused by: java.lang.NoSuchMethodError: org.jgroups.JChannel.<init>(Ljava/net/URL;)V"}}

4

1 回答 1

1

我从 wildfly 10 升级到 wildfly 18 时遇到了同样的问题;我为 infinispan 和 jgroups 使用 xml 配置文件。如果您不需要自定义 jgroups.xml 文件,只需使用位于 infinispan-core-9.4.16.Final.jar/default-configs 中的 default-jgroups-udp.xml。通过查看 infinispan 和 jgroups 源代码,我找到了一种避免调用缺失方法的方法。

我设置了以下解决方法:

import com.google.common.io.ByteSource;
import org.apache.deltaspike.core.api.config.ConfigProperty;
import org.infinispan.commons.util.FileLookupFactory;
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
import org.infinispan.configuration.parsing.ParserRegistry;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;

@ApplicationScoped
public class IspnCacheManagerProducer {
    private String configurationFile = "/path/to/file/cache.xml";

    private String jgroupsConfigurationFile = "/path/to/file/jgroups.xml";

    private EmbeddedCacheManager cacheManager;

    @PostConstruct
    private void init() {
        try {
            InputStream is;
            is = new FileInputStream(new File(jgroupsConfigurationFile));
            ByteSource byteSource = new ByteSource() {
                @Override
                public InputStream openStream() {
                    return is;
                }
            };
            String text = byteSource.asCharSource(StandardCharsets.UTF_8).read();
            is.close();

            InputStream configurationStream = FileLookupFactory.newInstance().lookupFileStrict(configurationFile, Thread.currentThread().getContextClassLoader());
            ConfigurationBuilderHolder holder = new ParserRegistry().parse(configurationStream);
            holder.getGlobalConfigurationBuilder().transport().addProperty(JGroupsTransport.CONFIGURATION_STRING, text);
            holder.getGlobalConfigurationBuilder().transport().removeProperty(JGroupsTransport.CONFIGURATION_FILE);

            cacheManager = new DefaultCacheManager(holder, true);
            configurationStream.close();
        } catch(IOException e) {
            throw new RuntimeException("Exception occured during cache manager initialization", e);
        }
    }
}

如果将它与自定义 jgroups 文件一起使用,则还必须删除 cache.xml 文件中的 < jgroups > 标记。

使用 wildfly10 / infinispan 8,我的代码如下。我的 jgroups.xml 文件在 config.xml 文件中得到解决。

import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import java.io.IOException;

@ApplicationScoped
public class IspnCacheManagerProducer {
    private String configurationFile = "/path/to/file/cache.xml";

    private EmbeddedCacheManager cacheManager;

    @PostConstruct
    private void init() {
        try {
            cacheManager = new DefaultCacheManager(configurationFile);
        } catch(IOException e) {
            throw new RuntimeException("Exception occured during cache manager initialization", e);
        }
    }
}
于 2020-06-26T14:18:54.680 回答