[jboss-user] [EJB 3.0] - Getting an EntityManagerFactory from within a Servlet (JBoss

SmokingAPipe do-not-reply at jboss.com
Thu Dec 21 19:31:24 EST 2006


I'm writing an app that is mainly a Seam application, but there's one operation where I want a plain old Servlet.  I could use plain old JDBC within the Servlet, but I don't want to.  Instead I want to get a proper EntityManager.

I understand that I can't use injection in a Servlet because there aren't (yet) lifecycle hooks to make annotations do their injection.  Also I can't get just one EntityManager for the Servlet because EntityManagers are not thread-safe.  So I need to use an InitialContext to get an EntityManager factory and use that.

But I can't figure out what is the JNDI name of the EntityManagerFactory!  It all works fine in my Seam application, where I'm using a Seam-managed persistence context.  What name do I use for the EntityManagerFactory in this case?

Thanks


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

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



More information about the jboss-user mailing list