[jboss-user] [EJB/JBoss] - Stateful + PreDestroy + EntityManager = NullPointerException

Alesque do-not-reply at jboss.com
Sun May 20 01:07:53 EDT 2007


Hi,

I?m currently working on a stateful session bean (jboss 4.2.0.CR2) and I need some help.

In the annotated pre destroy method I get an exception if one method of the Hibernate session is invoked.

Caused by: java.lang.NullPointerException
  |         at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getNonTxEntityManager(ManagedEntityManagerFactory.java:59)
  |         at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getTransactionScopedEntityManager(ManagedEntityManagerFactory.java:164)
  |         at org.jboss.ejb3.entity.hibernate.TransactionScopedSessionInvocationHandler.getSession(TransactionScopedSessionInvocationHandler.java:71)
  |         at org.jboss.ejb3.entity.hibernate.TransactionScopedSessionInvocationHandler.getHibernateSession(TransactionScopedSessionInvocationHandler.java:62)
  |         at org.jboss.ejb3.entity.hibernate.TransactionScopedSessionInvocationHandler.invoke(TransactionScopedSessionInvocationHandler.java:96)
  |         at $Proxy112.load(Unknown Source) 
  | 
The code fragment:

public class CombinationWriterBean implements CombinationWriter {
  | 
  |     @PersistenceContext( unitName = "MyPu" )
  |     private Session session;
  | 
  |     [ ? ]
  | 
  |     @PreDestroy
  |     public void destroy() {
  |         getLogger().info("Invoking destroy method...");
  | 
  |         if ( ! isCommitted() ) {
  |             this.session.load( this.revision, this.revision.getId() );
  |             this.session.delete( this.revision );
  |         }
  |     }
  | }

Is this a bug or this design is not compliant with EJB specs. Is there an existing workaround to this issue?

Any help would be appreciated.

Regards,
Alexandre

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047036#4047036

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047036



More information about the jboss-user mailing list