[ https://issues.apache.org/jira/browse/DELTASPIKE-1424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17297492#comment-17297492 ]
Mark Struberg commented on DELTASPIKE-1424: ------------------------------------------- +1 Do you have an EAR scenario? In which case it is a known bug in some newer Containers. Using the option Thomas mentioned switches back to the old CDI-1.0 mechanism we still have around in DeltaSpike. > 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)