• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

contextDestroyed() method is not calling

 
Ramkumar Umayal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And those methods are in the com.ciena.ss.core.ScheduleScan class?
 
Ramkumar Umayal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Ulf Dittmer. The methods are in com.ciena.ss.core.ScheduleScan class only.
 
Niraj Jha
Ranch Hand
Posts: 63
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you annotated class with @WebListener ?
 
Ramkumar Umayal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you start or stop your server is it inside eclipse or command prompt?
 
Ramkumar Umayal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat is running in a Solaris machine.
I use command prompt to do start and stop.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic