-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: persistence-context-ref problem
PostPosted: Fri Mar 09, 2007 11:05 am 
I can successfully use an EntityManger that has been injected into a stateless session bean using an @PersistenceContext(unitName="Dictionary") annotation.

If I try to set up a reference to the same unit using an ejb-jar.xml as shown:

Code:
   
<enterprise-beans>
  <session>
    <ejb-name>Ejb3EntityDescriptorServiceBean</ejb-name>
    <persistence-context-ref>
      <persistence-context-ref-name>persistence/Dictionary</persistence-context-ref-name>
      <persistence-unit-name>Dictionary</persistence-unit-name>
      <injection-target>
        <injection-target-class>net.sf.moksha.ejb3.util.impl.Ejb3EntityDescriptorServiceBean</injection-target-class>
        <injection-target-name>_em</injection-target-name>
      </injection-target>
    </persistence-context-ref>
  </session>   
</enterprise-beans>


The container (JBoss 4.0.5.GA as set up by JEMS installer 1.0.2.GA) starts ok and my code runs as far as being able to print out the type of the injected entity manager:

Code:
14:50:02,531 DEBUG [Ejb3EntityDescriptorServiceBean] _em is: org.jboss.ejb3.entity.TransactionScopedEntityManager@e229be


However, any attempt to get the _em reference to do "anything useful" in a method annotated with @PostConstruct results in a stack trace that ends:

Code:
Caused by: java.lang.NullPointerException
   at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getNonTxEntityManager(ManagedEntityManagerFactory.java:58)
   at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getTransactionScopedEntityManager(ManagedEntityManagerFactory.java:163)
   at org.jboss.ejb3.entity.TransactionScopedEntityManager.contains(TransactionScopedEntityManager.java:198)
   at net.sf.moksha.ejb3.util.impl.Ejb3EntityDescriptorServiceBean.init(Ejb3EntityDescriptorServiceBean.java:87)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(LifecycleInvocationContextImpl.java:159)
   at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(LifecycleInterceptorHandler.java:109)
   ... 57 more


I'm convinced that the unit name and bean name are correct.

I'm less sure about persistence-context-ref-name, what should this point to?

Has anyone got ejb-jar.xml based injection of a persistence unit working?

Thanks

Andy


Top
  
 
 Post subject:
PostPosted: Sun Mar 11, 2007 8:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Good question, can you open a JIRA issue with your test case attached here http://jira.jboss.com/jira/browse/EJBTHREE

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 4:42 am 
Will do, though it may not be till the end of tomorrow.

Cheers,

Andy


Top
  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 9:09 am 
Issue created:

http://jira.jboss.com/jira/browse/EJBTHREE-912

Cheers,

Andy


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.