This discussion is archived
2 Replies Latest reply: Feb 9, 2011 1:41 PM by 834789 RSS

ClassCastException in JNI

834789 Newbie
Currently Being Moderated
Hi All,

Below is the code in my Oracle Forms to call a web service:

-- Method: authenticate (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
FUNCTION authenticate(
obj ORA_JAVA.JOBJECT,
a0 VARCHAR2,
a1 VARCHAR2) RETURN VARCHAR2 IS

BEGIN

args := JNI.CREATE_ARG_LIST(2);
JNI.ADD_STRING_ARG(args, a0);
JNI.ADD_STRING_ARG(args, a1);

message('here1');

RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'mypackage/AuthenticatorWebServiceServiceStub',
'authenticate', '(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;', args);

message('here2');

END;

However when the above code is invoked it shows the message 'here1' on the form and then throws the following exception: java.lang.Exception: java.lang.ClassCastException

Please suggest me what's wrong with the code. I appreciate your time and help.

Thanks,
Scott.

Edited by: Scott on Feb 9, 2011 8:05 AM
  • 1. Re: ClassCastException in JNI
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    First that isn't "JNI".

    JNI is a specification related to java which allows java and other language to interact in the same process.

    Conversely you are obviously using a PL/SQL package. The fact that is named 'JNI' means nothing.

    Is that even an Oracle system package? I couldn't find Oracle docs for it.

    The exception seems obvious. And the most likely sources are your arguments or the return type.
  • 2. Re: ClassCastException in JNI
    834789 Newbie
    Currently Being Moderated
    Hi jschell,

    That code is auto generated by Oracle forms when a java class is imported. I couldn't find much documentation on the JNI methods but here is a link where Oracle talks a little bit about that:
    http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=3&vtTopicFile=java_importer/jimp_introduction.html&vtTopicId=

    It says: You can conveniently access the imported Java through the generated PL/SQL using the new ORA_JAVA package and its built-ins. Internally, the generated PL/SQL packages use the Java Native Interface (JNI) standard.

    I double checked the arguments and all. Nothing seems wrong. I am in a very bad situation as there isn't any documentation available on the JNI methods used in this code.

    Thanks for your time.

    - Scott.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points