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

jaikiran do-not-reply at jboss.com
Fri Nov 30 08:53:08 EST 2007


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
  | 
  | } 
  | .....
  | }


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

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



More information about the jboss-user mailing list