uCosminexus Application Server, Expansion Guide
This subsection describes the processing, for which you must take care when creating a batch application, and the functionality that you cannot use in a batch application. Confirm these contents, and then create a batch application.
You must take care of the following processing, when creating a batch application:
Do not operate the following files and directories in a batch application:
When handling the files and directories in a batch application, you cannot use a relative path as a path of the files and directories. If you want to acquire a relative path from a directory by executing the cjexecjob command, use the value of ejbserver.batch.currentdir. For details on ejbserver.batch.currentdir, see ejbserver.batch.currentdir property in the uCosminexus Application Server API Reference Guide.
The following example shows how to modify a batch application.
Before modification
File f = new File("DataFile.txt");
After modification
File f = new File(System.getProperty("ejbserver.batch.currentdir") + System.getProperty("file.separator") + "DataFile.txt");
A batch server does not wait for end of thread that is created or started by a batch application. When using threads in a batch application, you implement in such a way so that all the started user threads are completed before ending the batch application. User threads are out of scope of method cancellation.
If true is specified in the ejbserver.batch.application.exit.enabled parameter in the Easy Setup definition file, note the following points:
If a thread created by a batch application remains, the classes of the batch application or the used resources are not released. As a result, when you attempt to start next batch application, the batch application might fail to start. In a user thread, you cannot invoke the following batch server functionality:
On a batch server, a batch application is executed on JavaVM of the server. Therefore, if the implementation expects the processing of automatically closing resources, as a part of ending JavaVM, memory or file descriptor leakage might occur. For example, leakage occurs in the following cases:
To avoid these problems, implement batch applications in such a way so that the resources close properly.
If you do not explicitly close files and sockets, the timing of resource release is indefinite. This might impact the execution of subsequent batch applications. Make sure to explicitly close files and sockets.
In the case of a batch server, you cannot use automatic closing of connection. Make sure to close connection inside batch applications.
If you specify true in the ejbserver.batch.application.exit.enabled parameter in the Easy Setup definition file, you can use the following JavaVM end methods:
For details on the settings of the ejbserver.batch.application.exit.enabled parameter, see 2.3.10 Settings in the execution environment (batch server settings). For details on the points to be considered when using the JavaVM end methods, see (3) Points to be considered when using JavaVM end method.
If you specify true in the ejbserver.batch.application.exit.enabled parameter in the Easy Setup definition file, you can use shutdown hook in the following cases:
For details on the settings of the ejbserver.batch.application.exit.enabled parameter, see 2.3.10 Settings in the execution environment (batch server settings).
You cannot use the following functionality in a batch application. Take actions by using the procedure shown in Action.
You cannot perform input processing from standard input that uses java.lang.System.in.
You cannot use the execution functionality of native libraries through JNI.
You cannot use the following method:
You cannot use the following methods:
If you specify true in the ejbserver.batch.application.exit.enabled parameter in the Easy Setup definition file, JavaVM is not ended even if you use the JavaVM end method in a batch application. In such case, you can end only the thread invoked by the JavaVM end method.
This subsection describes the points to be considered when using the JavaVM end method if you have specified true in the ejbserver.batch.application.exit.enabled parameter.
The specifications of the JavaVM end method used in a batch application are different from the Java language specifications. The following table describes the differences with Java language specifications.
Table 2-10 Differences with Java language specifications
| Field | In Java language specification | In batch application |
|---|---|---|
| End target | JavaVM | Thread which invoked JavaVM end method |
| java logic coded after invocation | Processing, coded after invoking JavaVM end method, is not executed. | Processing, coded after invoking JavaVM end method, is executed in the following cases:
|
| Multiple invocation | Cannot be used. | Multiple invocation is performed in the following cases:
|
#1: You might not be able to end the thread, if an exception occurs in the finally block and in the method invoked in the finally block, and execution of the finally block is interrupted in middle without catching the exception in the finally block.
In the following cases, the time might be required for ending a thread or you might not able to end the thread:
An infinite loop, monitor waiting by the synchronized statement, and waiting by java.lang.wait() are processes of a Java program that require time.
#2: User thread shows a child thread created by a batch application. Take care of the following, when using user threads:
This subsection describes a processing, when you invoke JavaVM end method for each batch application.
Table 2-11 Operations when JavaVM end method is invoked for multiple times (In the case of a batch application implemented with a single thread)
| No. | Field | Operation |
|---|---|---|
| 1 | End reporting to batch application execution functionality | Report end only when you invoke first JavaVM end method. Do not report when you invoke second or later JavaVM end method. |
| 2 | Returning end code | The end code, specified in argument, is enabled when you invoke first JavaVM end method. The end code, specified in argument, is disabled when you invoke second or later JavaVM end method. |
| 3 | Thread, which invoked JavaVM end method | The thread ends irrespective of number of invocation of JavaVM end method. |
All Rights Reserved. Copyright (C) 2013, 2015, Hitachi, Ltd.