When developing an Java EE Application, I often came across the 'problem' to do stuff when the application is started, stopped etc. Now for Weblogic for example, there is a mechanism for that (the application life-cycle listener). But if you want to keep your application free from stuff that is app. server specific, you have to find a different solution. Some recommend using a servlet that is loaded on start-up, and "abuse" the init()
/destroy()
.
Others say use a ServletContextListener
. To me, the last one sounds best (according to the java doc for ServletContextListener
. Unfortunately, today I tried JBoss 7, where it seems that jax-ws webservices are initialized before any other Servlet
, thus before the ServletContextListener
gets a notification.
Long story short - am I just facing some app server specific issues here - or is there any "more appropriate", standardized Java EE way to register things, do stuff, before any webservice, servlet, whatsoever is initialized?