[jboss-user] [JBoss Seam] - EntityManager in StartupServletContextListener

labo do-not-reply at jboss.com
Fri Mar 2 04:05:52 EST 2007


Hello, 

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 
adding 

 @In
   private EntityManager em;

and then use

em.createQuery.....


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 :-(



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

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



More information about the jboss-user mailing list