14 November 2006

Executing Scripts Using admin_client.jar

The command line utility admin_client.jar is used to perform deployment and other sorts of administrative operations against an OC4J instance.

Typically the operations are called from the command line on a one by one basis.

A little extra feature admin_client has is the ability to execute a script that contains a set of commands to perform.

Besides enabling scripts to be developed that capture a sequence of related (or common) operations, another benefit of this is that admin_client.jar establishes the connection once, and then executes the commands in the script using the same connection.

A script simply contains the list of admin_client commands to execute, in their normal form.

For example, to stop an application, then perform a redeployment, the script would contain:
  -stop  myApp
-redeploy -file d:\temp\myapp.ear -deploymentName myapp -bindAllWebApps

To execute the script, admin_client.jar is invoked as normal with the deployer_uri and the authentication details, but instead of providing a command to execute you specify the -script option and feed it the script to use.
C:\oc4j\j2ee\home>java -jar admin_client.jar
deployer:oc4j:localhost oc4jadmin welcome1 -script script.txt

06/11/15 20:53:00 Notification ==>Stopping manageable object:
oc4j:j2eeType=J2EEApplication,name=myapp,J2EEServer=standalone
06/11/15 20:53:00 Notification ==>Stop completed for state manageable object:
oc4j:j2eeType=J2EEApplication,name=myapp,J2EEServer=standalone
06/11/15 20:53:01 Notification ==>Uploading file myapp.ear ...
06/11/15 20:53:01 Notification ==>Application Deployer for myapp STARTS.
...


Related documentation.

4 comments:

Anonymous said...

This admin.jar command you talk about seems really cool. Does this mean, I could include within an application itself, maybe even some BPEL type code.

What are your thoughts on this ?
Is this something you would recommend ?
Are there any examples out there?

George

Buttso said...

George, how wonderful to hear from you again.

The admin_client.jar utility deploys J2EE archives into OC4J.

If you have BPEL code, then you'll need to deploy that to the BPEL PM using its deployment facilities.

Anonymous said...

It is cool.

I always had a problem with admin_client.jar from bash script. It always return exit code of "0". I guess one should not use it in non-interactive mode...

Anonymous said...

Yes I have noticed that as well, it always return 0 (success) even when there are errors and deployment failed!! Is there a way around it.. like getLastError or getStatus etc??

S