13 November 2006

Starting and Stopping Applications On OC4J

A handy but little known feature with OC4J 10.1.3 is the ability to selectively start and stop applications that are deployed to an OC4J instance.

In previous releases, it was always possible to start/stop an OC4J instance, but it wasn't possible to start/stop the individual applications that are deployed to an OC4J instance.

The application start/stop operations are exposed in multiple places.

  1. Within Application Server Control

    This is relatively straight forward, so I'll leave it to you to play with.

  2. Within admin_client.jar

    Stop operation:
    >java -jar admin_client.jar
    deployer:oc4j:localhost oc4jadmin [password] -stop myApp

    Notification ==>Stopping manageable object:
    oc4j:j2eeType=J2EEApplication,name=myAppJ2EEServer=standalone

    Notification ==>Stop completed for state manageable object:
    oc4j:j2eeType=J2EEApplication,name=myApp,J2EEServer=standalone

    The new state of the application is written in the server.xml file:
    <application name="myApp" path="../applications/myApp.ear"
    parent="default" start="false" />

    Start operation:
    >java -jar admin_client.jar
    deployer:oc4j:localhost oc4jadmin [password] -start myApp

    Notification ==>Starting manageable object:
    oc4j:j2eeType=J2EEApplication,name=myAppJ2EEServer=standalone

    Notification ==>Start completed for state manageable object:
    oc4j:j2eeType=J2EEApplication,name=myApp,J2EEServer=standalone

    <application name="myApp" path="../applications/myApp.ear"
    parent="default" start="true" />

  3. Using the Oracle Ant tasks <oracle:stop> and <oracle:start>

    Stop operation:
    <target name="stopapp">
    <echo message="-----> Stopping application" />
    <oracle:stop
    deployerUri="deployer:oc4j:localhost"
    userid="oc4jadmin" password="welcome1"
    deploymentName="myApp"
    />
    </target>

    Buildfile: build.xml

    stopapp:
    [echo] -----> Stopping application
    [oracle:stop] Stopping application testpermgen.
    [oracle:stop] 06/11/14 15:42:45 Notification ==>
    Stop completed for state manageable object:
    oc4j:j2eeType=J2EEApplication,name=myApp,J2EEServer=standalone

    And the same pattern for the start operation.
    <target name="startapp">
    <echo message="-----> Starting application" />
    <oracle:start
    deployerUri="deployer:oc4j:localhost"
    userid="oc4jadmin" password="welcome1"
    deploymentName="myApp"
    />
    </target>

    Buildfile: build.xml

    startapp:
    [echo] -----> startping application
    [oracle:start] Starting application myApp.

    [oracle:start] 06/11/14 15:47:48 Notification ==>
    Starting manageable object:
    oc4j:j2eeType=J2EEApplication,name=myApp,J2EEServer=standalone

    [oracle:start] 06/11/14 15:47:48 Notification ==>
    Start completed for state manageable object:
    oc4j:j2eeType=J2EEApplication,name=myApp,J2EEServer=standalone

    [oracle:start] Application myApp started.
You can now have multiple applications all deployed to an OC4J instance and only start those applications you need at any point in time.

No comments: