views:

110

answers:

1

I have a J2EE app and it has a listener in web.xml.

Listener contains a method called contextInitialized

I want to know when does contextInitialized actually get called?

From my reading I understand that it gets called when deploying the application. Can there be situations/scenario's where it could be called after the application has been deployed? Say that I am in a Clustered GlassFish app server environment. Could it be called after the application has been deployed?

+1  A: 

It's called once when the application is first deployed. It shouldn't get called again if the application stays deployed.

However, the application may go through the undeploy/deploy cycle while the server is running. For example, you can set it up so that the application is redeployed when a file is changed in the directory.

ZZ Coder
Exactly, from the [API doc](http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContextListener.html): *Notification that the web application initialization process is starting.*
BalusC