0 Replies Latest reply on Mar 2, 2007 4:05 AM by Jörg Larbig

    EntityManager in StartupServletContextListener

    Jörg Larbig Newbie


      I am running Seam 1.2.0 in a Tomcat 6 container.
      I am using the JPA to access my database.
      DB access works fine for "simple" controllers by

      private EntityManager em;

      and then use


      In order to load reference data I want to write my own
      StartupServletContextListener e.g.

      public class MyStartupServletContextListener extends org.apache.myfaces.webapp.StartupServletContextListener{

      public void contextInitialized(javax.servlet.ServletContextEvent event){

      ServletContext srvcon = event.getServletContext();


      The context listener is registered in the web.xml file.

      How can I access the EntityManager in my contextInitialized method ?

      The same way than in my controllers will cause a Nullpointer...

      The same problem occurs when trying to write my own
      SessionListener :-(