Hitachi

uCosminexus Application Server Expansion Guide


2.3.2 Executing batch applications

You use the cjexecjob command to start batch applications. When execution of the main method of a batch application ends, the batch server performs Full GC. This subsection describes how to start batch applications, and processing for starting and ending the batch applications.

If you want to stop a running batch application, you forcefully stop the batch application. For details on how to forcefully stop the batch applications, see 2.3.3 Forcefully stopping a batch application.

Organization of this subsection

(1) How to start batch applications

This subsection describes how to start batch applications.

You use the cjexecjob command to start a batch application. You use the following three methods execute the cjexecjob command:

  1. Method for directly executing the cjexecjob command

    You start a batch application by using this method, if you do not want to use JP1/AJS, BJEX, and JP1/Advanced Shell.

  2. Method for defining the cjexecjob command as a JP1/AJS job and executing from JP1/AJS

    You start a batch application by using this method, if you use only JP1/AJS.

  3. Method for defining the cjexecjob command as a BJEX job step and executing a BJEX job from JP1/AJS

    You start a batch application by using this method, if you use JP1/AJS and BJEX.

  4. Method for using and executing the adshjava command provided by JP1/Advanced Shell from the job definition script file of JP1/Advanced Shell

    Start a batch application by using this method if you want to use JP1/Advanced Shell. With this method, you can directly execute JP1/Advanced Shell or you can also execute JP1/Advanced Shell via JP1/AJS.

For details on the definitions of JP1/AJS, BJEX and JP1/Advanced Shell jobs that are used when starting a batch application with method 2, 3, and 4, see 2.13 Integrating with JP1/AJS.

You start a batch server in advance for executing a batch application from JP1/AJS, BJEX, and JP1/Advanced Shell.

(2) Processing of starting a batch application

If you specify a class name and class path of a batch application in the cjexecjob command, the batch application specified in the cjexecjob command starts. The following processing is executed when you start a batch application:

  1. Output a message (KDJE55000-I) stating that processing of a batch application starts.

  2. Output a message (KDJE55001-I) stating that the main method of the batch application starts.

  3. Execute the public static void main(String[]) method or the public static int main(String[]) method.

When starting a batch application, the public static void main(String[]) method or the public static int main(String[]) method of an execution class that is specified in the cjexecjob command is invoked. For method arguments, you set up the arguments specified after class name of the cjexecjob command.

If an attempt to start a batch application fails

If the main method is not defined in a batch application, an attempt to start the batch application fails. If an attempt to start the batch application fails, the batch server and the cjexecjob command operate as follows:

  • Batch server operation

    The batch server outputs a message, and returns the information stating failure in starting the batch application with message string to the cjexecjob command.

  • The cjexecjob command operation

    The command outputs the message string received from the batch server and forcefully stops the application. 1 is returned as a return value of the command.

The following table describes the conditions when an attempt to start a batch application fails, and the messages output by a batch server.

Table 2‒3: Conditions where an attempt to start a batch application fails

Condition where an attempt to starting batch application fails

Message output by batch server

An attempt to read usrconf.properties (user property file for batch application) fails.

KDJE55035-E

The class specified in the cjexecjob command does not exist.

KDJE55006-E

The public static void main(String[]) method or the public static int main(String[]) method is not defined.

Signatures of both the public static void main(String[]) method and the public static int main(String[]) method are different.

java.lang.NoClassDefFoundError occurs when loading a class specified in the cjexecjob command.

KDJE55007-E

A class required for invoking the public static void main(String[]) method or the public static int main(String[]) method is not found.

An error occurs in the static{} block.

You cannot execute the main method due to a problem other than those mentioned above.

KDJE55008-E

(3) Processing of ending a batch application

The batch application processing ends after execution of the main method is complete. The processing executed at the end a batch application is as follows:

  1. Output a message (KDJE55002-I) stating that the end processing of a batch application starts.

  2. Output a message (KDJE55003-I) stating that the end processing of a batch application is complete.

  3. Perform Full GC.

  4. Send the end code of the batch application to the cjexecjob command.

The following table describes the end conditions of batch applications and operations of batch servers and the cjexecjob command during that time.

Table 2‒4: End conditions of batch applications

End condition of batch application

Batch server operation

cjexecjob command operation

The main method is executed until end.

Outputs the KDJE55002-I message and ends the execution of the batch application. Outputs the KDJE55003-I message after ending the application.

Ends normally.

Return value: 0

The return statement is executed using the public static void main(String[]) method.

return end-code is executed using the public static int main(String[]) method.

Ends normally.

Return value: end code specified in return

A class that inherits java.lang.Throwable or java.lang.Throwable is thrown outside the main method.

Outputs the KDJE55009-E message. Outputs exception stack trace to exception log. Ends execution of the batch application.

Outputs exception stack trace to standard error output. Abnormally ends execution of the batch application.

Return value: 1

Batch server terminated (forced termination of batch server or unexpected down of JavaVM).

None.

Outputs the KDJE55021-E message and abnormally ends execution of the batch application.

Return value: 1

An execution of a batch application does not end even if you end the cjexecjob command by using Ctrl+C or signal during the execution of the batch application. Execute cjkilljob if you want to forcefully stop execution of a batch application. However, if you forcefully stop using the cjkilljob command, the end code of the cjexecjob command is indefinite. For details on the batch forced stop command, see 2.3.3 Forcefully stopping a batch application.

(4) Points to be considered when executing batch applications

If you invoke and use EJB or DB Connector from batch applications, existence of EJB and DB Connector to be used is not checked when you start the batch applications. If EJB or DB Connector referenced from the batch applications do not exist, a runtime error occurs during the execution of the batch applications. Before starting a batch application, check whether EJB at the reference location exists or not. When connecting to a database from a batch application by using DB Connector, keep the DB Connector started on the batch server.