Sebastian Łaskawiec created WFLY-4250:
-----------------------------------------
Summary: Manually created CDI producer methods in the Extension are not
injected
Key: WFLY-4250
URL:
https://issues.jboss.org/browse/WFLY-4250
Project: WildFly
Issue Type: Bug
Components: CDI / Weld
Affects Versions: 8.2.0.Final
Environment: Happened on Linux environment
Reporter: Sebastian Łaskawiec
Assignee: Stuart Douglas
h2. Issue description:
During migration from Wildfly 8.1 to 8.2 (Weld 2.1.2.Final -> 2.2.6.Final) in
Infinispan we discovered a problem with injecting beans created programmatically in
Infinispan-cdi integration module. The problem appeared in {{GreetingServiceIT}} and
{{GreetingCacheManagerIT}} test. Both those tests use the following modules integrated
into Wildfly:
* org.infinispan.cdi (slot: ispn-7.1, which has dependency to "org.infinispan"
slot="ispn-7.1" export="true")
* org.infinispan.jcache (slot: ispn-7.1, which has dependency to
"org.infinispan" slot="ispn-7.1" and "org.infinispan.cdi"
slot="ispn-7.1" services="import")
[Infinispan's CDI
Extension|https://github.com/infinispan/infinispan/blob/master/cdi/src/ma...]
invokes [{{embeddedExtension.registerCacheBeans(event,
beanManager)}}|https://github.com/infinispan/infinispan/blob/master/cdi/s...],
which registers custom {{Cache}} and {{AdvancedCache}} producer beans. Those beans are
being successfully added to {{BeanManager}} but are never chosen for injection. All tests
fail because of unsatisfied dependencies for {{Cache<CacheKey, String>}} with
qualifiers {{@GreetingCache}}.
h2. Steps to reproduce:
* Download and unzip
[
https://github.com/slaskawi/infinispan/archive/upgrade_to_wf_8_2_failed_t...]
* Run {{./build.sh clean install -pl
cdi,as-modules/embedded,integrationtests/as-integration-embedded -am -DskipTests}}
* Modify Arquillian xml if breakpoint is needed
{{./integrationtests/as-integration-embedded/src/test/resources/arquillian.xml}}
* Run test (using IDE or Maven: {{./build.sh test -pl
integrationtests/as-integration-embedded -Dtest=GreetingServiceIT}})
h2. Finding during debugging:
At first I would suggest creating conditional breakpoints:
* {{org.jboss.weld.bootstrap.Validator}} line 370 (WF 8.2) or 366 (WF 8.1), condition
{{"[BackedAnnotatedField] @Inject @GreetingCache private
org.infinispan.test.integration.as.cdi.GreetingServiceIT.greetingCache".equals(ij.toString())}}
- this will stop debugger when validating injection points for {{{GreetingCache}}.
* {{org.jboss.weld.resolution.TypeSafeResolver.ResolvableToBeanCollection}} line 51,
condition {{from.toString().startsWith("Types:
[org.infinispan.Cache<javax.cache.annotation.CacheKey, java.lang.String>]") ||
from.toString().contains("org.infinispan.Cache")}} - this stops debugger on
loading {{Cache}} producer methods (created in Infinispan CDI Extension) to {{resolved}}
Loading Cache in Wildfly 8.1.
During debugging session we discovered that the beans from Infinispan's CDI Extension
are created but never used for injection. This is because {{beanManager.getBeans(ij)}} in
{{Validator.java}} always return empty list. In Wildfly 8.1 beans are properly resolved
using {{ResolvableToBeanCollection#load}} method, but for some reason it never happens in
Wildfly 8.2, because those beans are already preset in {{resolved}} Loading Cache with
empty collection value. Unfortunately we couldn't find answer why.
h2. Workaround:
In order to fix CDI Producer Beans accessibility we need to add a new dependency to our
test: {{META-INF/MANIFEST.MF: Dependencies: org.infinispan:ispn-7.1}}.
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)