[jboss-user] [EJB 3.0] - Re: Use of CMP EntityManager in POJO

voidhawc do-not-reply at jboss.com
Tue May 5 02:40:00 EDT 2009


Found what could be the problem.

This is the code that causes the null pointer in 4.2.3.GA


  | public EntityManager getNonTxEntityManager()
  |    {
  |       Map map = nonTxStack.get();
  |       EntityManager em = (EntityManager)map.get(this); // Null Pointer here
  |       if (em == null)
  |       {
  |          em = entityManagerFactory.createEntityManager();
  |          map.put(this, em);
  |       }
  |       return em;
  |    }
  | 

Compared against the JPA code.


  | public EntityManager getNonTxEntityManager()
  |    {
  |       Map<ManagedEntityManagerFactory, EntityManager> map = nonTxStack.get();
  |       
  |       EntityManager em = null;
  |       if (map != null)
  |          em = map.get(this);
  |       else
  |       {
  |          map = new HashMap<ManagedEntityManagerFactory, EntityManager>();
  |          nonTxStack.push(map);
  |       }
  |       
  |       if (em == null)
  |       {
  |          em = entityManagerFactory.createEntityManager();
  |          map.put(this, em);
  |       }
  |       return em;
  |    }
  | 

As you can see there is a guard around the map reference code. However the code with a guard around it appears to from revision 75254 where as the code without a guard is from 75965 which is later. 

However the 4.2 code appears to have been copied from 4.0 (rev 58000). 

Does anyone happen to know which release this was fixed in?

Thanks

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

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



More information about the jboss-user mailing list