• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Listening to servlet.init() events.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Currently i am trying to build up a spring based application, where in the cases of any exceptions/errors being thrown while intialization of the context, the application itself should be brought down.
1. creating a appContext.xml where DBs are being initialized.
2. Cases where db isn't getting initialized since the context couldn't be initialized completely, we will get Servlet.init() error.
3. I want to intercept in between these two steps, where the application itself should be brought down,  in case of any errors

I have tried the following:
1. Using the error location handler in web.xml, creating a json stating that some error had occured. But this is not pre emptive, as in the application will keep on running.
2. Using events hook provided by spring, but there are only five of these: context start/stop/refresh/close/request handling. I have tried exploring custom events being raised, but I don't know where/how to publish/subscrive to these events.

can someone please help ?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't worked with Spring but for vanilla servlets, one would typically use a ServletContextListener
Your initialization code would go inside the contextInitialized() method.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic