[jboss-user] [EJB 3.0] - Re: Accessing EntityManagerFactory/SessionFactory via JNDI s

jaikiran do-not-reply at jboss.com
Wed Sep 3 03:48:06 EDT 2008


How about changing your code to:

  | InitialContext ctx = new InitialContext();
  | NamingEnumeration<Binding> list = ctx.listBindings("persistence-units");
  | while (list.hasMore()) {
  | 	Binding nc = (Binding)list.next();
  | 	System.out.println("Persistence Unit EMF is relative : " + nc.isRelative() + " name: " + nc.getName()+" [class: "+nc.getClassName()+"]");
  | 
  | 	Object o = ctx.lookup("persistence-units/" + nc.getName());
  | 
  | 	if(!(o instanceof EntityManagerFactory)) {
  | 		System.out.println("No good; o instance of "+o.getClass().getName());
  | 	}
  | 	else {
  | 			System.out.println("Got it again!");
  | 	}
  | }

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

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



More information about the jboss-user mailing list