[jboss-user] [EJB 3.0] - Re: EJB3.0 SESSIONBEAN WORK WITH HIBERNATE EXCEPTION

paul_lmc do-not-reply at jboss.com
Thu Jun 26 10:00:22 EDT 2008


IN THE CONTEXTLISTENER LIKE THIS :

public class StartUpListener implements ServletContextListener{

	public void contextDestroyed(ServletContextEvent arg0) {

	}
	public void contextInitialized(ServletContextEvent arg0) {
		try {
			InitialContext ctx = new InitialContext();
			HibernateUtil h = new HibernateUtil();
			h.Init();
			SessionFactory newsf = h.sf;
			SessionFactory oldsf = (SessionFactory)ctx.lookup("hibernateJNDI");
			System.out.println("bind hibernateJNDI~~~~~~~~~~~~~~~~~~~~~~~`");
			if(oldsf!=null) ctx.rebind("hibernateJNDI", newsf);
			else ctx.bind("hibernateJNDI", newsf);
			
		} catch (NamingException e) {
			e.printStackTrace();
		}		
	}
}

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

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



More information about the jboss-user mailing list