4 Replies Latest reply on May 5, 2009 10:19 AM by 699752

    ORA-29549: class SOME.SYSTEM CLASS has changed, Java session state cleared

    369038
      I am using a javamail program to send emails, and occasionally receive the following:

      ORA-29549: class SOME.SYSTEM CLASS has changed, Java session state cleared

      This causes the calling program to fail, and pagers go off. I have scoured the internet looking for a way to handle the error. Most discussions I find on this suggest to just call the procedure again and it works the second time. That's true if you call it from a new session, but there is not a way to catch the ora-29549 in plsql and then call the same plsql java wrapper function again - you will again receive ora-29549. Any suggestions on how to get around this one? I need to be able to catch the error and handle it by successfully sending out the emails. One workaround I had thought of was to call this java mailer every morning and send a dummy email to myself, so that if the process fails it is not failing for a production-critical process. That seems like a pretty rudimentary workaround - I would think it should be possible to handle the error in plsql somehow. Since there was not much out there on the web I thought I would begin this thread. Any suggestions are greatly appreciated - thanks in advance.
        • 1. Re: ORA-29549: class SOME.SYSTEM CLASS has changed, Java session state cleared
          damorgan
          You can easily trap ORA-29549 or any other Oracle exception code. Just look up PRAGMA EXCEPTION_INIT.
          http://www.psoug.org/reference/pragma.html
          follow the link and find the pragma demo.
          • 2. Re: ORA-29549: class SOME.SYSTEM CLASS has changed, Java session state cleared
            369038
            Thank you for your post. I am able to trap the ora-29549 error but at that point there is nothing I can do. What I have read regarding this error was to ignore it and just call the java wrapper function again, it will work the second time. So I trap the error, and try to call the same function again, but it fails again. If I let my script finish and then run it again, then the call will work. Here is a demo case:

            --create java object
            CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "testc" AS
            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';

            --call function
            DECLARE
            RESULT NUMBER;
            BEGIN
            RESULT := TEST;
            END;

            --recompile java source
            alter java source "testc" compile

            --call function again, error occurs     
            DECLARE
            RESULT NUMBER;
            BEGIN
            RESULT := TEST;
            END;

            --call function a second time, no error occurs
            DECLARE
            RESULT NUMBER;
            BEGIN
            RESULT := TEST;
            END;

            --recompile java source again
            alter java source "testc" compile

            --try to trap exception and call function again
            DECLARE
            RESULT NUMBER;
            javasessionstate EXCEPTION;
            PRAGMA EXCEPTION_INIT (javasessionstate, -29549);
            BEGIN
            RESULT := TEST;
            EXCEPTION
            WHEN javasessionstate
            THEN
            RESULT := TEST;
            END;
            • 3. Re: ORA-29549: class SOME.SYSTEM CLASS has changed, Java session state cleared
              699752
              I am having the same problem. Any ideas?
              • 4. Re: ORA-29549: class SOME.SYSTEM CLASS has changed, Java session state cleared
                699752
                Hmm, after tryin a bit I found the solution:

                Issue a DBMS_JAVA.ENDSESSION_AND_RELATED_STATE in the exception handler like:

                DECLARE
                JAVA_SESSION_CLEARED EXCEPTION;
                PRAGMA EXCEPTION_INIT(JAVA_SESSION_CLEARED, -29549);
                --
                V_KEEP_TRIES NUMBER := 3;
                V_TMP VARCHAR2(32000);
                BEGIN
                <<BEFORE_JAVA_CALL>>
                BEGIN

                JAVA_WRAPPER_PROC;

                EXCEPTION
                WHEN JAVA_SESSION_CLEARED THEN
                V_TMP := DBMS_JAVA.ENDSESSION_AND_RELATED_STATE;
                V_KEEP_TRIES := V_KEEP_TRIES - 1;
                IF V_KEEP_TRIES >= 0 THEN
                GOTO BEFORE_JAVA_CALL;
                ELSE
                RAISE;
                END IF;
                WHEN OTHERS THEN
                LM.SET_STATUS('FAILED', SQLERRM );
                RAISE;
                END;