Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Standardized" way of handling the lifecycle of a Java EE application

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?

like image 750
DXTR66 Avatar asked Jul 22 '11 08:07

DXTR66


People also ask

What is EE in Java?

Java Platform, Enterprise Edition (Java EE) is the standard in community-driven enterprise software. Java EE is developed using the Java Community Process, with contributions from industry experts, commercial and open source organizations, Java User Groups, and countless individuals.


1 Answers

If your webservices are annotated like this

@javax.jws.WebService(...)
public interface YourServiceEndpoint

they are no real servlets yet, but JBoss (Jax-WS) will turn them into a startup.

I am using jboss-4.2.3 and I am also getting these messages before my ServletContextListner is called.

[org.jboss.wsf.framework.management.DefaultEndpointRegistry] register: jboss.ws:context=crm,endpoint=YourService

But I wonder, if this webservice is available before the complete application has started because nearly at the end of deployment I get following messages

[org.jboss.wsf.stack.jbws.WSDLFilePublisher]  WSDL published to: ... YourServlet(..).wsdl

So I would guess, that this is a jboss related issue. Maybe we should test on another app server to proof so.

like image 147
powerMicha Avatar answered Oct 26 '22 23:10

powerMicha