Wildfly 10 Infinispan configuration
jperezbrockhaus Mar 17, 2017 3:20 AMI have tried to configure a local cache for the Infinispan subsystem of Wildfly 10. I am using the standalone-full.xml file for it.
<cache-container name="box" default-cache="myCache" jndi-name="infinispan/box"> <local-cache name="myCache" jndi-name="infinispan/box/mycache"/> </cache-container>
I have a module where it is located a GenericDAO along with the entity manager within it. In this module I have the following CacheBean:
package de.brockhaus.cot.entity; import javax.annotation.Resource; import javax.enterprise.inject.Produces; import javax.faces.bean.ApplicationScoped; import org.infinispan.Cache; @ApplicationScoped public class CacheBean { @Produces @Resource(name="myCache") private Cache<Long, BaseEntity> cache; }
This bean is injected into the GenericDAO like this:
@Inject Cache<Long, BaseEntity> cache;
There is a web application that imports the module above. In its pom I have added the following lines:
<build> <sourceDirectory>src/main/java</sourceDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.5.1</version> <configuration> <archive> <manifestEntries> <Dependencies>org.infinispan org.infinispan.commons org.jboss.as.clustering.infinispan export</Dependencies> </manifestEntries> </archive> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.0.0</version> <configuration> <warSourceDirectory>src/main/webapp</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> <archive> <manifestEntries> <Dependencies>org.infinispan org.infinispan.commons org.jboss.as.clustering.infinispan export</Dependencies> </manifestEntries> </archive> </configuration> </plugin>
In the web.xml of the web app I have added:
<resource-ref> <res-ref-name>myCache</res-ref-name> <lookup-name>java:jboss/infinispan/box/mycache</lookup-name> </resource-ref>
When I deploy the web app and try to use it, I am getting the following error:
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.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:64) at org.jboss.as.ejb3.component.stateless.StatelessSessionComponent$1.create(StatelessSessionComponent.java:61) at org.jboss.as.ejb3.pool.AbstractPool.create(AbstractPool.java:56) at org.jboss.as.ejb3.pool.strictmax.StrictMaxPool.get(StrictMaxPool.java:124) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:47) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:254) ... 166 more Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: Can not set org.infinispan.Cache field de.brockhaus.cot.entity.CacheBean.cache to org.jboss.as.clustering.infinispan.DefaultCache at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277) at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:344) at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) ... 175 more
I have tried to use the class org.jboss.as.clustering.infinispan.DefaultCache instead of org.infinispan Cache but the error is similar:
Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: Can not set org.jboss.as.clustering.infinispan.DefaultCache field de.brockhaus.cot.entity.CacheBean.cache to org.jboss.as.clustering.infinispan.DefaultCache
.cache to org.jboss.as.clustering.infinispan.DefaultCache