aspose file tools*
The moose likes Servlets and the fly likes contextDestroyed() method is not calling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "contextDestroyed() method is not calling" Watch "contextDestroyed() method is not calling" New topic
Author

contextDestroyed() method is not calling

Ramkumar Umayal
Greenhorn

Joined: Oct 13, 2009
Posts: 18
Dear all,

I have a class which implemented SevletContexListener interface. I have overridden contextDestroyed() and contextInitialized() methods.
Here is my web.xml(Highlighed in Green my Listener class]

The problem is whenever tomcat is restarted the contextDestroyed() method is not calling.
Could you please clarify me where i am committing mistakes... Thanks in advance

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>Browser</display-name>

<listener>
<listener-class>com.ciena.ss.core.ScheduleScan</listener-class>
</listener>


...

</web-app>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
So contextInitialized is called, but not contextDestroyed? Just to make sure: are you using "Override" annotations to make sure you didn't make a spelling mistake?
Ramkumar Umayal
Greenhorn

Joined: Oct 13, 2009
Posts: 18
No Both methods are not called... i have used the annotations properly. For your observation i am just capturing those methods here...

These logs are not printing..

@Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
System.out.println("#####################################");
Log.info(" Server is restarting.");
System.out.println("#####################################");
}


/* (non-Javadoc)
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
@Override
public void contextInitialized(ServletContextEvent arg0) {
// TODO Auto-generated method stub
System.out.println("#####################################");
System.out.println("Server is started");
System.out.println("#####################################");
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
And those methods are in the com.ciena.ss.core.ScheduleScan class?
Ramkumar Umayal
Greenhorn

Joined: Oct 13, 2009
Posts: 18
Yes Ulf Dittmer. The methods are in com.ciena.ss.core.ScheduleScan class only.
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

Have you annotated class with @WebListener ?
Ramkumar Umayal
Greenhorn

Joined: Oct 13, 2009
Posts: 18
Hi Niraj

Servlet 3.0 only supports the @WebListener. I am using 2.4.
So I have to depend upon only on the web.xml.

Could you please suggest me on this.

Regards,
Ram
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

How you start or stop your server is it inside eclipse or command prompt?
Ramkumar Umayal
Greenhorn

Joined: Oct 13, 2009
Posts: 18
Tomcat is running in a Solaris machine.
I use command prompt to do start and stop.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: contextDestroyed() method is not calling