Andrei Ivanov created DELTASPIKE-1350:
-----------------------------------------

             Summary: TransactionalInterceptor should use the 
EntityManagerResolver for lookups
                 Key: DELTASPIKE-1350
                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1350
             Project: DeltaSpike
          Issue Type: Improvement
          Components: JPA-Module
    Affects Versions: 1.8.2
            Reporter: Andrei Ivanov


Hi,

I'm trying to use the transaction support from the JPA module with multiple 
entity managers that are created by a producer defined in a separate/common 
module.

That means that any specific qualifiers defined in the client modules (like 
{{@DbA}} / {{@DbB}}{{}} from the examples) are not visible to the producer. To 
make this work, I've followed the approach from the 
{{EntityManagerFactoryProducer}} and I've defined my own qualifier, 
{{PersistenceContextName}}, duplicated from {{PersistenceUnitName}} (and 
similar to the {{CustomQualifier}} from the example).

I've also created an {{EntityManagerResolver}} in one of the client modules and 
configured it in the DAOs inside it (which are not DeltaSpike repositories), 
with {{@Transactional}} and {{@EntityManagerConfig(entityManagerResolver = 
BranchManagementResolver.class, qualifier = PersistenceContextName.class)}}

As far as I see, only the {{qualifier}} attribute is used, but it invokes my 
producer with a {{null}} {{InjectionPoint}}:
{noformat}
java.lang.NullPointerException: null
    at 
EntityManagerProducer.getEntityManagerFactory(EntityManagerProducer.java:109) 
~[server-core-impl-1.0.21-SNAPSHOT.jar:?]
    at EntityManagerProducer.createEntityManager(EntityManagerProducer.java:95) 
~[server-core-impl-1.0.21-SNAPSHOT.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[?:1.8.0_172]
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:1.8.0_172]
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_172]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_172]
    at 
org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.injection.producer.ProducerMethodProducer.produce(ProducerMethodProducer.java:103)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:161)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:180) 
~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) 
~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700) 
~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:723) 
~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86)
 ~[weld-core-impl-3.0.4.Final.jar:3.0.4.Final]
    at 
org.apache.deltaspike.jpa.spi.entitymanager.QualifierBackedEntityManagerResolver.resolveEntityManager(QualifierBackedEntityManagerResolver.java:59)
 ~[deltaspike-jpa-module-api-1.8.2.jar:1.8.2]
    at 
org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy.resolveEntityManagerForQualifier(ResourceLocalTransactionStrategy.java:381)
 ~[deltaspike-jpa-module-impl-1.8.2.jar:1.8.2]
{noformat}
{{That line has LOGGER.info("Annotated: {}", injectionPoint.getAnnotated()), 
and {{injectionPoint}} is null.}}

Maybe this is a separate bug?

 

If I understand this correctly, my problem would be solved if my custom 
resolver would be used for lookups, but the only reference to it is from 
{{EntityManagerRefLookup#lookupReference}}, and that just got removed from 
{{TransactionStrategyHelper}}.

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to