Oracle - Java/JSERVER - Debug Load / Compilation

> Database > Oracle Database

1 - About

When you load Java unit, you can get such error:

java.sql.SQLException: ORA-24344: success with compilation error
ORA-06512: at line 1

	at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
	at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
       ...........

How can we resolve this error ?

3 - How to get the error ?

SELECT name, TYPE, SEQUENCE, substr(text,0,100) FROM user_errors;

Result:

NAME“TYPE”“SEQUENCE”“SUBSTR(TEXT,0,100)”
com/ciber/Salesforce“JAVA CLASS”1“ORA-29535: source requires recompilation”
Salesforce“JAVA SOURCE”1“Salesforce:74: incompatible types”
Salesforce“JAVA SOURCE”2“found : int”
Salesforce“JAVA SOURCE”3“required: java.lang.Integer”
Salesforce“JAVA SOURCE”4“ Integer countLine = 0;”
Salesforce“JAVA SOURCE”5“ ”
Salesforce“JAVA SOURCE”6“Salesforce:75: incompatible types”
Salesforce“JAVA SOURCE”7“found : int”
Salesforce“JAVA SOURCE”8“required: java.lang.Integer”
Salesforce“JAVA SOURCE”9“ Integer nbHeaderSeparator = 0;”
Salesforce“JAVA SOURCE”10“ ”
Salesforce“JAVA SOURCE”11“Salesforce:76: incompatible types”
Salesforce“JAVA SOURCE”12“found : int”
Salesforce“JAVA SOURCE”13“required: java.lang.Integer”
Salesforce“JAVA SOURCE”14“ Integer nbSeparator = 0;”
Salesforce“JAVA SOURCE”15“ ”
Salesforce“JAVA SOURCE”16“Salesforce:79: operator ++ cannot be applied to java.lang.Integer”
Salesforce“JAVA SOURCE”17“ countLine++;”
Salesforce“JAVA SOURCE”18“ ”
Salesforce“JAVA SOURCE”19“Salesforce:84: operator ++ cannot be applied to java.lang.Integer”
Salesforce“JAVA SOURCE”20“ nbSeparator++;”
Salesforce“JAVA SOURCE”21“ ”
Salesforce“JAVA SOURCE”22“Salesforce:87: operator == cannot be applied to java.lang.Integer,int”
Salesforce“JAVA SOURCE”23“ if (countLine == 1) {”
Salesforce“JAVA SOURCE”24“ ”
Salesforce“JAVA SOURCE”25“Salesforce:92: incompatible types”
Salesforce“JAVA SOURCE”26“found : int”
Salesforce“JAVA SOURCE”27“required: java.lang.Integer”
Salesforce“JAVA SOURCE”28“ nbSeparator = 0;”
Salesforce“JAVA SOURCE”29“ ”
Salesforce“JAVA SOURCE”30“Salesforce:95: operator - cannot be applied to java.lang.Integer,int”
Salesforce“JAVA SOURCE”31“ nbSeparator = nbSeparator - 1;”
Salesforce“JAVAOURCE”32“ ”
Salesforce“JAVA SOURCE”33“8 errors”

Solution in this case: change integer with int in the java class

Integer countLine = 0;

was become

int countLine = 0;
Advertising

4 - How to resolve the java class ?

First, get the correct name of the object:

SELECT object_name, object_type, STATUS
FROM user_objects
WHERE object_type LIKE '%JAVA%';

Then resolve it:

Before resolution of the problem:

SQL> ALTER JAVA class "com/gerardnico/Salesforce" resolve;
 
Warning: JAVA altered WITH compilation errors.

After the resolution:

SQL> ALTER JAVA class "com/gerardnico/Salesforce" resolve;
 
JAVA altered.

5 - Redirecting the output to SQL*Plus Text Buffer

As in previous releases, you can use the DBMS_JAVA package procedure SET_OUTPUT to redirect output to the SQL*Plus text buffer:

SET SERVEROUTPUT ON
CALL dbms_java.set_output(2000);

The minimum and default buffer size is 2,000 bytes and the maximum size is 1,000,000 bytes. In the following example, the buffer size is increased to 5,000 bytes:

SQL> SET SERVEROUTPUT ON SIZE 5000
SQL> CALL dbms_java.set_output(5000);

The output is displayed at the end of the call.

Example of result:

SQL> call AlterSalesforceFile();
AlterSalesforceFile started
Error: the Permission (JAVA.io.FilePermission /transfer/salesforce_original read) 
has NOT been granted TO STG. The PL/SQL TO grant this IS dbms_java.grant_permission( 'STG', 
'SYS:java.io.FilePermission', '/transfer/salesforce_original', 'read' )
 
Call completed.
Advertising

6 - Documentation / Reference

db/oracle/java_debug.txt · Last modified: 2017/09/06 19:28 by gerardnico