[jboss-user] [JNDI/Naming/Network] - Re: Configuring persistence unit and accessing EntityManager

jsolderitsch do-not-reply at jboss.com
Fri Nov 30 09:52:50 EST 2007


"jaikiran" wrote : anonymous wrote : @WebService()
  |   | @PersistenceContext(name = "persistence/LogicalName", unitName = "MissionStatusProjectPU2")
  |   | public class MissionStatusService {
  |   | 
  |   | EntityManager em;
  |   | 
  |   | public MissionStatusService() {
  |   | 
  |   | try {
  |   | Context ctx = (Context) new javax.naming.InitialContext().lookup("java:comp/env");
  |   | em = (EntityManager) ctx.lookup("persistence/LogicalName");
  |   | } catch (NamingException ex) {
  |   | ex.printStackTrace();
  |   | }
  |   | 
  |   | } 
  | 
  | How about this:
  | 
  | 
  |   | @WebService()
  |   | public class MissionStatusService {
  |   | 
  |   | @PersistenceContext
  |   | EntityManager em;
  |   | 
  |   | public MissionStatusService() {
  |   |  //do nothing
  |   | 
  |   | } 
  |   | .....
  |   | }
  | 

I did try that.

Then my web service handler that uses the em to create the response fails with a null pointer error for em.

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

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



More information about the jboss-user mailing list