Startup and shutdown classes for J2EE enterprice application


General J2EE: Startup and shutdown classes for J2EE enterprice application

  1. Hi all,

       My J2EE enterprise application (ear) needs some initialization (preparation , caching various data, prepare db DataSource, bind some singeltons onto JNDI). All is now implemented using T3Startup classes (they are accessible from part of WLS EAR,WAR,...).
       However because these startup classes are dependent on common application classes, part of the enterprise application needs to be placed in weblogic classpath.
       I d like to have all stuff within EAR file. All application stuff should be re-deployed so that I can not restart app. server. I am using J2EE compliant WLS 7.
       Is there any way to make startup and shutdown classes placed within EAR ? I have these ideas about that :

    1. WLS 8 has specific feature in weblogic-application description to assign them in
    <startup> and shutdown tags.
    Or you can define your classloader behaviour in this descriptor.

    2. for WLS 7 there is no such mechanism. However this is what I found in documentation :

    If the application is an EAR, the individual components are loaded in the order in which they are declared in the application.xml deployment descriptor. See Editing Enterprise Application Deployment Descriptors.

    that means that I can place Web application on first place, it contains startup servlet that can do initialization stuff in init and destroy methods of servlet (load on startup would be set to 1). That way I think I can make redeployment of startup classes. I am not sure for that way.

      Can You please correct me or suggest some other way how to start and shutdown classes for application (but not T3startup way)thanks
  2. This is one possible way (assuimg you have WAR file deployed), you could add load-on-starup in your web.xml as given below


    and also in your servlet class, have a static block which will kick off your initialization sequence.

    Hope this helps
  3. :-)

    I have also found this problem in the startup classes. But sorry, I don't have any solution to it besides putting all you class files outside the EAR file and only have the deployment descriptors in the EAR file.