You can identify Java code errors and locate the source of Java code errors for a Java transformation in the compilation results of the Java tab. Java transformation errors might occur because of an error in the Java editor or because of an error in the full code for the Java transformation class.
To troubleshoot a Java transformation:
•Find the source of the error in the Java code snippets or in the full class code for the transformation.
•Identify the type of error using the compilation results and the location of the error.
After you identify the source and type of error, fix the Java code on the Java tab and compile the transformation again.
Finding the source of compilation errors
When you compile a Java transformation, results are displayed in the compilation results. If the compilation succeeds, the compilation results displays the message, "Compilation Successful." If the compilation fails, the compilation results displays the compilation errors and error locations.
Compilation errors can occur in the following locations:
Java editor
If the error is located in a code snippet in Java editor, Data Integration lists the section and the line that contains the error. Data Integration also highlights the source of the error in the Java editor.
Full code
If the error is located in the full code, Data Integration lists the error location as "Full Code" and lists the line in the Full Code dialog box that contains the error.
You can locate errors in the Full Code dialog box, but you cannot edit the Java code. To fix errors that you find in the Full Code dialog box, edit the code in the appropriate section. You might need to use the Full Code dialog box to view errors caused by adding user code to the full class code for the transformation.
Identifying the error type
Compilation errors can appear as a result of errors in the user code. Errors in the user code might also generate an error in the non-user code for the class.
Compilation errors can be of the following types:
User code errors
Errors can occur in the user code in different sections of the Java editor. User code errors include standard Java syntax and language errors. User code errors might also occur when Data Integration adds the user code to the full class code.
For example, a Java transformation has an input field with a name of int1 and an integer data type. The full code for the class declares the input field variable with the following code:
int int1;
However, if you use the same variable name in the On Input Row section, the Java compiler issues an error for a redeclaration of a variable. To fix the error, rename the variable in the On Input Row section.
Non-user code errors
User code in sections of the Java editor can cause errors in non-user code.
For example, a Java transformation has an input field, int1, and an output field, out1, with integer data types. You enter the following code in the On Input Row section to calculate interest for input field int1 and assign it to output field out1:
When you compile the transformation, Data Integration adds the code from the On Input Row section to the full class code for the transformation. When the Java compiler compiles the Java code, the unmatched brace causes a method in the full class code to end prematurely, and the Java compiler issues an error.