1 Reply Latest reply on Dec 23, 2006 6:17 PM by Andrew Rubinger

    Getting an EntityManagerFactory from within a Servlet (JBoss

    None None Master

      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