• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

contextDestroyed() method is not calling

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Ulf Dittmer. The methods are in com.ciena.ss.core.ScheduleScan class only.
 
Ranch Hand
Posts: 63
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you annotated class with @WebListener ?
 
Ramkumar Umayal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat is running in a Solaris machine.
I use command prompt to do start and stop.
 
reply
    Bookmark Topic Watch Topic
  • New Topic