Thursday, July 05, 2007

Automatically Executing a Client Application Archive

Many applications have a requirement that they want to automatically execute an application client archive(CAR) packaged as a part of enterprise application (EAR) when server starts up or an application is restarted. This is a Java EE 5 standard compliant alternative to Startup class about which I blogged about 2 and half years back!

In this article, I will outline steps to do this in OC4J.

  • Develop and compile your application client class. This class must contain a main method that will be called by your server during startup.

  • Create a META-INF/ file for the application-client, for example
    Manifest-Version: 1.0
    Main-Class: OracleASStartup

  • Create a deployment descriptor for the application client (application-client.xml) as follows:

  • Create the application client archive (CAR) file for your startup class with the above Manifest and deployment descriptor.

  • Create an EAR file for the application client module with the an OC4J-specific deployment descriptor orion-application.xml as follows:
    <client-module path="startup-client.jar" start="true" user="anonymous" >
    </orion-application >

  • Build your EAR and deploy your application with auto start set to "true" as follows in the server.xml:<application name="startup"
    path="../applications\startup.ear" parent="default" start="true" >

Whenever your application is deployed or if you restart your server, the application client will be executed automatically!

Hope this helps!

1 comment:

Karthik said...

Hey Debu,

Maybe you are the best resource for this question.

Are these components compatible with each other?

Java 5.0
EJB 3.0= Using session beans and Entity beans (Toplink implementation)
JSF = MyFaces 1.1.4 with Facelets
Contained in OC4J 10.3.2

I can't seem to instantiate a session bean, but I wonder if an application can be deployed in these conditions?


-Karthik Gaekwad