Document Type | Technical Information
Category | App Development
Applicable Product Version | Tibero7.2.4
Document Number | TDETI015
Overview
In Tibero, objects created as Java classes can be used by communicating with JAVA EPA. At this time, the created Java classes are generated as physical .class files in the path set by the JAVA_CLASS_PATH parameter.
In a TAC environment, if this path is not a shared storage area, caution is required because a TBR-150008 error may occur due to file mismatch between nodes.
Method
Operation Comparison by Configuration Type
1. When using local storage area (error occurs)
The physical file (.class) is created only on the node where the Java class was created. Other nodes recognize the metadata but cannot use the object because the actual file does not exist.
- Node 1: The actual .class file is created and function call works normally
SQL> CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "JavaExtproc" AS
public class SimpleMath { public static int findMax(int x, int y)
{if (x >= y) return x;
else return y; } }
/
Java Source 'JavaExtproc' created.
SQL> CREATE OR REPLACE FUNCTION find_max(x PLS_INTEGER, y PLS_INTEGER)
RETURN PLS_INTEGER IS
LANGUAGE JAVA NAME 'SimpleMath.findMax(int, int) return int';
Function 'FIND_MAX' created
SQL> select find_max(4,60) from dual;
FIND_MAX(4,60)
--------------
60
1 row selected.
- Node 2: Metadata is shared so function object creation is possible, but error occurs on call due to missing file
SQL> select find_max(4,60) from dual; TBR-150008:Invalid class name. - SimpleMath at line 1, column 2 of null: select find_max(4,60) from dual ^
Note
If the .class file from Node 1 is manually copied to the same path on Node 2, it can be called successfully without restarting.
2. When using shared storage area (recommended)
Configure so that all nodes can access the physical files in the same path. Since the source created on Node 1 is stored in the shared storage, it can be used immediately on all nodes.
- Configuration method ($TB_HOME/config/$TB_SID.tip)
JAVA_CLASS_PATH="/shared_storage_area"
Note
If not set, the default path = DB_CREATE_FILE_DEST/java)
- Node 1 and Node 2: Calls succeed on both nodes
SQL> CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "JavaExtproc" AS
public class SimpleMath { public static int findMax(int x, int y)
{if (x >= y) return x;
else return y; } }
/
Java Source 'JavaExtproc' created.
SQL> CREATE OR REPLACE FUNCTION find_max(x PLS_INTEGER, y PLS_INTEGER)
RETURN PLS_INTEGER IS
LANGUAGE JAVA NAME 'SimpleMath.findMax(int, int) return int';
Function 'FIND_MAX' created
SQL> select find_max(4,60) from dual;
FIND_MAX(4,60)
--------------
60
1 row selected.
Conclusion
When utilizing Java classes in a TAC environment, it is recommended to set JAVA_CLASS_PATH to a shared storage area. This is an essential setting to maintain data consistency between nodes and to ensure service continuity in case of failures.