0

ContextInitialized doesn't get call

asked 2013-02-20 11:36:53 +0800

kkwebdev02 gravatar image kkwebdev02
1

Hello,

I create Class HibernateListener(implements ServletContextListener) to initialization my HibernateFactory for the first time when tomcat start. Why contextInitialized doesn't get call when the tomcat start? but when tomcat stop, contextDestroyed will called. Thank you

Example my code : public class HibernateListener implements ServletContextListener{

@Override
public void contextInitialized(ServletContextEvent sce) {
    HibernateUtil.getSessionFactory();
}

@Override
public void contextDestroyed(ServletContextEvent sce) {
    HibernateUtil.getSessionFactory().close();
}

}

Listener on web.xml : <listener> <listener-class>com.myproject.HibernateListener</listener-class> </listener>

delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-02-20 11:36:53 +0800

Seen: 4 times

Last updated: Feb 20 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More