Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1080485

Summary: CDI cache injection fails due to incompatible types
Product: [JBoss] JBoss Data Grid 6 Reporter: Vojtech Juranek <vjuranek>
Component: EAP modulesAssignee: Tristan Tarrant <ttarrant>
Status: CLOSED NOTABUG QA Contact: Martin Gencur <mgencur>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: afield, dereed, dmehra, mgencur, mmarkus
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-26 16:27:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
reproducer none

Description Vojtech Juranek 2014-03-25 14:21:23 UTC
Created attachment 878483 [details]
reproducer

Description of problem:
When trying to inject a cache predefined in EAP config file via @Resource annotation, it fails due to incompatible types (see exception bellow).

Version-Release number of selected component (if applicable):
EAP 6.2.1 and JDG 6.3.0.DR1 EAP modules

Steps to Reproduce:
1. User attached EAP config file (standanlone.xml)
2. Deployed attached web app 
3. navigate to http://localhost:8080/infinispan-cdi/index.jsf


Actual results:
Caused by: java.lang.IllegalArgumentException: Can not set org.infinispan.Cache field org.infinispan.quickstart.cdi.GreetingCacheManager.cache to org.jboss.as.clustering.infinispan.DefaultCacheContainer$DelegatingCache
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [rt.jar:1.7.0_45]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [rt.jar:1.7.0_45]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.7.0_45]
        at java.lang.reflect.Field.set(Field.java:741) [rt.jar:1.7.0_45]
        at org.jboss.weld.introspector.jlr.WeldFieldImpl.set(WeldFieldImpl.java:88) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:154) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.util.Beans.injectEEFields(Beans.java:713) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:164) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:161) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:135) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:157) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:297) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) [weld-core-1.1.17.Final-redhat-1.jar:1.1.17.Final-redhat-1]
        at org.infinispan.quickstart.cdi.GreetingCacheManager$Proxy$_$$_WeldClientProxy.getCacheName(GreetingCacheManager$Proxy$_$$_WeldClientProxy.java) [classes:]

Expected results:
Web app is deployed and works fine

Comment 2 dereed 2014-03-26 03:11:28 UTC
That's expected behavior.  

The Infinispan subsystem in EAP is separate from JDG.

Comment 3 Vojtech Juranek 2014-03-26 08:34:10 UTC
When I bundle JDG libs in deployed war, it work without any problem. As the cache is defined in EAP config file (i.e. handled by ISPN subsystem), it should IMHO work or fail equally in both cases. Such inconsistent behavior is IMHO a bug.

Comment 4 dereed 2014-03-26 15:30:46 UTC
It shouldn't work in that case either, since EAP's org.infinispan.Cache is different than JDG's org.infinispan.Cache visible to the war.
(EAP's caches can never be used by an application using JDG because of basic classloading rules)

The only way that would work is if it's importing EAP's ISPN modules, which would override the packaged JDG.

Note that using EAP's ISPN caches in an application is a completely unsupported use case.

Comment 5 Vojtech Juranek 2014-03-26 16:27:05 UTC
@dereed thanks for clarification, I re-checked with Martin Genrur that using EAP's ISPN caches in an application is really unsupported, so closing as not a bug.