File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes contextDestroyed- odd behaviour? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "contextDestroyed- odd behaviour?" Watch "contextDestroyed- odd behaviour?" New topic

contextDestroyed- odd behaviour?

John Jones

Joined: Feb 17, 2005
Posts: 1
I have a very simple class that implements ServletContextListener.
When Tomcat is shut down, contextDestroyed is run, but the context variables are already null when I try to access them. Is this the appropriate behaviour? I would have thought they would not destroyed until after contextDestroyed finishes running.
I wrote a simple jsp page as well to make sure that I could access the variable before shutdown.
I am running Tomcat 5.5.7 on Windows 2000.

Here is my code:

Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Did you configure your implementation class in the deployment descriptor of your web application?

And the "test" JSP page is included in the same web application?
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
This sounds more like a JSP/Servlet issue than a Apache/Tomcat?
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

I just tested your code in TC5.28 and it seems to be working fine.
Here is the output to catalina.out, generated when reloading the app from the html manager in Tomcat:

==> catalina.out <==
- Reloading this Context has started
test = This is a test

I've bundled the test into a war file:
Try with this war file.

If I get a chance later, I'll try in 5.5.7

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: contextDestroyed- odd behaviour?
It's not a secret anymore!