Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to call contextDestroyed()?  RSS feed

 
sriram sundararajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i configured one listener class inside the web.xml. That Listener class implements ServletContextListener,HttpSessionListener. I noticed that on starting of the weblogic server contextInitialized() method calls, then what about contextDestroyed() method when will it call?

In the specification it is mentioned like this "Notification that the servlet context is about to be shut down. All servlets have been dstroy()ed before any ServletContextListeners are notified of context destruction. "

When this situation occurs. I manually tries to call destroy
() method from the service but it didn't work out, i knew very well that destroy() calls by the container and not by the programmer and also it is not a good procedure to call destroy() but i wanted to execute contextDestroyed() thatz why i tried eventhough its not working. How should i execute this contextDestroyed() method.

regards
sri
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to call the method manually?
Your listener should implement the contextDestroyed method - according to the API that will be called by the servlet engine automatically. Do you have any indication that this is not working as advertised?
Bill
 
sriram sundararajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i manually shutdown the server,but it is not calling contextDestroyed() method.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you shut it down?
If you used the normal shutdown and contextInitialized is getting called but contextDestroyed is not, I think you have found a bug.
 
sriram sundararajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
normal shutdown in the sense i pressed cntl-c in the console, it shutdown after that.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not the best way to shutdown - use the shutdown.bat script for an orderly shutdown.
Bill
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!