[
https://issues.apache.org/jira/browse/DELTASPIKE-1424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17297698#comment-17297698
]
Mark Struberg commented on DELTASPIKE-1424:
-------------------------------------------
Glad it worked! Regarding bug fix: you have to ask Wildfly guys to fix it, as
it's not a bug in DeltaSpike.
A quick explanation: Long before CDI introduced CDI.current() we already had
our BeanManagerProvider/BeanProvider couple (the later internally uses the
former). This observes BeforeBeanDiscovery and also has an injection of
BeanManager. This bm gets stored away in the Extension. This works very robust,
but might create mem leaks in very seldom cases where some Containers (afair
WLS) do not fire the BeforeShutdown for all ClassLoaders which got triggered
with BeforeBeanDiscovery. That was the initial reason to switch to using
{{CDI.current()}} via Reflection. This works perfectly fine in all WAR
scenarios and many containers with EARs as well. But on some Containers this
leads to a nasty bug as you did encounter yourself. Using this magic flag
should do the trick though.
> BeanProvider.getContextualReference Failing After Upgrading to v1.9.2
> ---------------------------------------------------------------------
>
> Key: DELTASPIKE-1424
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-1424
> Project: DeltaSpike
> Issue Type: Bug
> Security Level: public(Regular issues)
> Components: Core
> Affects Versions: 1.9.2, 1.9.3, 1.9.4
> Environment: Ubuntu 18.04
> Java 1.8
> Jboss Wildfly 18.0.1
> Reporter: Patrick Buchheit
> Priority: Major
>
> I have been using deltaspike successfully to do injection of my entity
> manager into a non-bean class. Recently, I decided to upgrade from version
> 1.5.1 to the current version 1.9.4 to get access to variables in the
> apache-deltaspike.properties file. As soon as I made the change, I started
> seeing errors like this:
>
> {code:java}
> Caused by: java.lang.IllegalStateException: Could not find beans for
> Type=interface javax.persistence.EntityManager and
> qualifiers:[@com.tura.common.service.qualifier.EntityManagerQualifier()]Caused
> by: java.lang.IllegalStateException: Could not find beans for Type=interface
> javax.persistence.EntityManager and
> qualifiers:[@com.tura.common.service.qualifier.EntityManagerQualifier()] at
> org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:154)
> at
> org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:121)
> at
> org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:100)
> at
> com.tura.product.service.test.Test.testUploadFrameImages(Test.java:9702){code}
>
> Nothing in my code has changed; the only alteration I have made is to change
> the deltaspike version in my pom. Just to make sure, I tried rolling back to
> an earlier version of deltaspike. Versions 1.9.1 and earlier all work fine.
> As soon as I change to 1.9.2 or earlier I get an error. I couldn't find
> anything in the patch notes indicating changes I would need to make to
> migrate to a newer version. Is this a bug, or is there some change I need to
> make to my code to make it compatible again?
>
> Some code snippets:
>
> *entity manager lookup-*
> {code:java}
> EntityManager entityManager =
> BeanProvider.getContextualReference(EntityManager.class, new
> EntityManagerQualifierLiteral());{code}
>
> *Producer Bean*
>
> {code:java}
> @Alternative
> public class TestCDIModule
> {
> @PersistenceContext(unitName = "TestProductPersistenceUnit")
> private EntityManager entityManager;
>
> @Produces
> @EntityManagerQualifier
> public EntityManager getEntityManager()
> {
> return this.entityManager;
> }
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)