CDI beans result in the @Resource annotation being processed by Weld rather than the EE subsystem. To workaround this, create a <resource-ref/> or <resource-env-ref/> in your deployment descriptor and reference the @Resource by its mapped name. This way, the EE subsytem will process the deployment descriptor and weld will have no issues resolving the @Resource from the application/module namespace.
<resource-ref> <res-ref-name>testCache</res-ref-name> <lookup-name>java:jboss/infinispan/cache/test/default</lookup-name> <resource-ref>
@Resource(name="testCache") private Cache<String,String> testCache;
Thanks Paul but I don't have a servlet deployment descriptor (web.xml)... my application is packaged as a default switchyard deployment (jar file).
Do you know if another workaround exists? Currently I use a programmatically definition to solve it but I prefer to use an infinispan subsystem if can be possible....
I didn't say anything about needing a servlet deployment descriptor. Any EE deployment descriptor will do. I suggest creating an ejb-jar.xml or application-client.xml.
OK Paul. I will take into consideration the suggested change.