Using Startupclass in WebLogic 8.1

Discussions

General J2EE: Using Startupclass in WebLogic 8.1

  1. Using Startupclass in WebLogic 8.1 (4 messages)

    Hi,
       In our webservice development procedure we create a single EAR file to provide hot deployment. There are 5 war and 1 jar files within this EAR file.

       I need to specify one of the classes in the jar file as start-up class, but the server is not able to detect the class file (in the jar which in turn is in the EAR). It throws ClassNotFoundException.

       Can anybody please tell me how can I have a class file in the EAR and can specify it as start-up class on WebLogic 8.1 ?

       The basic requirement is to execute some code when the webservice server starts and before user hits first time.

    Regards,
    Vikas.
  2. I am not sure you can do that.

    The whole point of a startup class is to have code execute before your EAR is prepared for deployment. Having your startup class in the EAR defeats the above purpose.

    To deploy a startup class, the jar file containing the class should be in the classpath as used in your startup script.

    As far as the ClassNotfound.... goes, you should read the WebLogic Classloader documentation on how WLS loads classes for the server startup and application startup.
  3. I believe you have 2 ways how to make startup functionality :

    1. via WAR, servlet ; set the <load-on-startup> = 1 tag for servlet to provide intial invocation while the WAR is deployed

    2. using weblogic startup and shutdown mechanism for EAR,
    In the weblogic-application.xml ; placed the following

    <startup>
              <startup-class>MyStartup</startup-class>
              <startup-uri>MyArchive.jar</startup-uri>
          </startup>
          <shutdown>
              <shutdown-class>MyShutdown</shutdown-class>
              <shutdown-uri>MyArchive.jar</shutdown-uri>
          </shutdown>


    I used second approach, so everytime I re deployed the EAR application the shutdown class main method was executed and then startup class invoked.

    Hope this helps

    Roman
  4. good morning,

    me had the same issue as above
    and tried the
    <startup>
      <startup-class>MyStartup</startup-class>
      <startup-uri>MyArchive.jar</startup-uri>
    </startup>
    approach for starting up a class on weblogic startup

    however, the startup class uses some opensource third party utilities, like log4j and apache's quartz scheduler
    these jars arent found by weblogic's startup procedure and the following exception occurs:

    java.lang.reflect.InvocationTargetException

    Caused by: java.lang.NoClassDefFoundError: org/quartz/impl/StdSchedulerFactory

    how do i provide more jars into the startup class's path ?
    any pointers on this will be very helpful

    going, going, ... gone.
  5. found the solution to this.

    "manifest" file is the answer
    using a manifest file, one can point to the necessary jars

    for more information on manifest file in weblogic 8.1 :
    http://e-docs.bea.com/wls/docs81/programming/classloading.html#1068864