Injecting Inifinispan cache as a ConcurrentMap in WildFly 10
fernando.arbeiza Apr 13, 2016 8:26 PMHi all,
I am having some problems injecting an Infinispan cache in WildFly 10.
In WildFly 8.2.0, I had defined a cache as follows:
<cache-container name="mycontainer" start="EAGER"> <transport stack="tcp"/> <distributed-cache name="mycache" start="EAGER" jndi-name="java:/myapp/cache" mode="SYNC"/> </cache-container>
Then, I could use it, injecting it as a Concurrent map, as follows:
@Resource(lookup = "java:/myapp/cache") protected ConcurrentMap<Object, Object> cache;
In WildFly 10.0.0, I have tried to do the same:
<cache-container name="mycontainer" statistics-enabled="false"> <local-cache name="mycache" jndi-name="java:/myapp/cache" statistics-enabled="false"/> </cache-container>
But, somehow, I am getting an exception:
Caused by: java.lang.IllegalArgumentException: WFLYWELD0049: Error injecting resource into CDI managed bean. Can't find a resource named java:/myapp/cache defined on protected java.util.conc urrent.ConcurrentMap com.datagenic.glc2.cache.Caches.cache at org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices.resolveResource(WeldResourceInjectionServices.java:216) at org.jboss.as.weld.services.bootstrap.WeldResourceInjectionServices$1.createResource(WeldResourceInjectionServices.java:162) [...] Caused by: javax.naming.NameNotFoundException: myapp/cache [Root exception is java.lang.IllegalStateException] at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153) at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83) [...] Caused by: java.lang.IllegalStateException at org.jboss.msc.value.InjectedValue.getValue(InjectedValue.java:47) at org.jboss.as.naming.service.BinderService.getValue(BinderService.java:138)
I have tried some other combinations (such as getting it using java:jboss/infinispan/cache/mycontainer/mycache) but to no avail.
Could anyone give me a hint about what I may be missing here?
Thank you very much in advance.