The "normal" way this error can occur is to compile a java object in the database and execute it in the same session. E.g. (from http://forums.oracle.com/forums/thread.jspa?threadID=856644)
(Oracle 10gR2)
SQL> CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "testc" AS
public class testc {
public static int testm() {
return 0;
}
}
/
--create plsql wrapper function
public class testc {
public static int testm() {
return 0;
}
}
/
--create plsql wrapper function
create or replace FUNCTION TEST
RETURN NUMBER
IS
LANGUAGE JAVA
NAME 'testc.testm() return int';
cat call_test.sql
declare
result number;
begin
result :=test;
end;
/
declare
result number;
begin
result :=test;
end;
/
SQL> @call_test
PL/SQL procedure successfully completed.
Now alter the java object ...
PL/SQL procedure successfully completed.
Now alter the java object ...
SQL> alter java source "testc" compile;
Java altered.
SQL> @call_test
declare
*
ERROR at line 1:
ORA-29549: class USER1.testc has changed, Java session state cleared
ORA-06512: at "USER1.TEST", line 1
ORA-06512: at line 4
Java altered.
SQL> @call_test
declare
*
ERROR at line 1:
ORA-29549: class USER1.testc has changed, Java session state cleared
ORA-06512: at "USER1.TEST", line 1
ORA-06512: at line 4
Call it again and it executes sucessfully:
SQL> @call_test
PL/SQL procedure successfully completed.
Note that to produce the error, testc must be called first. If the java code is not called before the alter java, then the error does not occur, ie login, do some sql not involving testc, then alter java. After the alter java, calling testc does not produce any errors.
Looks like running the code sets some sort of session state for the java object, and this state conflicts with the results of the alter java, producing the error. If the state is not set first, then altering the java code does not cause any errors.
Running testc in a separate session never produces errors, whether run before or after the alter java.
SQL> alter system set events '29549 TRACE NAME ERRORSTACK LEVEL 3';
... generates trace file with the calling code (contents of call_test.sql).
Change to ERRORSTACK OFF when not required.
No comments:
Post a Comment