4.1.4.1.1. Launching the JSR352 Batch Application

4.1.4.1.1.1. Launch the batch application

In the case of JSR352-compliant batch application, the batch is launched using an API specified by JSR352.

Nablarch provides nablarch.fw.batch.ee.Main as the standard implementation class. This class specifies the XML file name (file name excluding .xml) of the target JOB as an execution argument.

To specify the parameters during job execution, specify the launch option for nablarch.fw.batch.ee.Main . The value specified in the launch option is configured in jobParameters of JobOperator#start .

For the launch option, add -- to the name and configure a value for the argument following the name.

Examples of using launch option
# In this example, two jobParameters "option1 = value1" and "option2 = value2" have been configured.
$ java nablarch.fw.batch.ee.Main jobName --option1 value1 --option2 value2

Tip

Even when creating a launch class in the project, it can be implemented by referring to the main class.

4.1.4.1.1.2. Exit code for batch application

The exit code for the main class program mentioned above is as follows.

  • Normal completion: 0 - When the exit status is other than “WARNING” and the batch status is BatchStatus.COMPLETED
  • Abnormal completion: 1 - When the exit status is other than “WARNING” and the batch status is not BatchStatus.COMPLETED
  • Warning completion: 2 - When the completion status is “WARNING”

If the JOB is interrupted while waiting for completion, it will return an abnormal completion code.

If errors such as a validation error have occurred, for which a warning has to be issued, then warning completion can be used. The method for warning completion is to call JobContext#setExitStatus(String) in chunk or batchlet, and configure the completion status as “WARNING”. Since the batch status permits an arbitrary value at the time of warning completion, even if an exception is thrown in chunk or batchlet and batch status is other than BatchStatus.COMPLETED , the above mentioned class ends with a warning if the completion status is configured as “WARNING”.

4.1.4.1.1.3. Initializing the system repository

System Repository can be initialized by configuring nablarchJobListenerExecutor .

Configure the file name of the root xml file of the system repository to batch-boot.xml and place it directly under the class path. The file name or location can be changed with the parameters of nablarchJobListenerExecutor .

An example is shown below.

Example of the default batch-boot.xml configuration file
<job id="sample-job" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
  <listeners>
    <!-- Configure nablarchJobListenerExecutor in job listener -->
    <listener ref="nablarchJobListenerExecutor" />
  </listeners>

  <!-- Step definition is omitted -->
</job>
Example of a configuration file other than default
<job id="sample-job" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
  <listeners>
    <listener ref="nablarchJobListenerExecutor">
      <properties>
        <!--
        Configures xml to read in diConfigFilePath properties
        In this example, "sample_project/batch-boot.xml" under the class path
        is loaded into the system repository
        -->
        <property name="diConfigFilePath" value="sample_project/batch-boot.xml" />
      </properties>
    </listener>
  </listeners>

  <!-- Step definition is omitted -->
</job>