Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listener

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This application is running on Tomcat 4.0.4. Servlet is set up to start when the server is started. There is a listener class entry which listens on connectionpooling class. Problem is this is getting closed first and then when Servlet is getting closed it was trying to do some meintenece on database and finding that there are no connections available and is giving errors. IS there away to change the order of things so the servlet is closed first and then the conection pool?


Thanks,

vasu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you'll want to read up on ServletContextListeners:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html

They were introduced in Servlet Spec 2.3 (which TC4 impliments).
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get you
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My point is to open and close your pool from the events in the contextListener, not a servlet. The contextInitialized event gets fired before the servlets get loaded. Visa versa for the closing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic