Platform: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 (A pleasure to have moved to Oracle 19c)
Hello, As always, my admiration for your time and expertise. After hours of exhaustive exploration and Oracle Docs and support pages, we were unable to solve this issue.
Utility: loadjava
Action: Trying to load a .jar file using loadjava and call Java Class using PL/SQL Api. This java class simply adds value to the JMS queue and returns a String with status as SUCCESS. Note: Hello.java worked successfully.
Issue: After a successful load using loadjava, When we execute via Oracle PL/SQL Function, we are getting the following error. “ORA-29532: Java call terminated by uncaught Java exception: javax.jms.JMSRuntimeException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory”
Our Trials: We thought it is missing some libraries of Weblogic. So we added wlthint3client.jar separately using loadjava utility. We also tried to add wlthint3client.jar under “ORACLEHOME\jdk\jre\lib\ext” so that it gets picked up at instance load. But the error keeps happening. We included this as a part of our original jar yet the same issue.
We went back to basics, and created both a Hello.java and Hello.class and loaded them using loadjava. With PL/SQL function called this class, and it worked successfully. Only when we load a .jar file it throws this ContextFactory error.
STEPS 1: under ORACLEHOME command prompt: loadjava -user userschema/password@instance -verbose -force JMessenger-1.0.jar.
It loaded successfully. Following is the output:
Classes Loaded: 97
Resources Loaded: 13
Sources Loaded: 0
Published Interfaces: 0
Classes generated: 0
Classes skipped: 0
Synonyms Created: 0
Errors: 0
STEPS 2 : Created an PL/SQL function:
CREATE OR REPLACE FUNCTION FUN_CALL_JAVA_TST RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'xyz.abc.messenger.producer.MessageProducer.testPing() return java.lang.String'; /
Step 3: We wrote a caller:
declare testoutput varchar2(100); begin testoutput := FUN_CALL_JAVA_TST(); dbms_output.put_line(testoutput); exception when others then dbms_output.put_line(sqlerrm); end;
Same error keeps coming.
Java Version in OracleHome installation: java version “1.8.0_201”
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode).
So we made sure to use the correct weblogic version libraries.
Kindly suggest what we are missing.
Sincerely, Aj
Hello Vinish. Yes I have these grants except (java.io.FilePermission), I will give that and try too. Our goal is to simply send a value from Pl/sql to Java which adds it to its JMS queue. These classes are bundled into a jar which loads successfully without error. When executed from Pl/sql throws the error “Cannot instantiate class: weblogic.jndi.WLInitialContextFactory”. Hence trying to load wlthint3client.jar, but we are not using -thin option of loadjava. That could be a reason. Or may be we should go with its previous version wlfullclient.jar and wlclient.jar. But haven’t tried those yet. May be you can suggest a much simpler solution that might ever require us using wlthint3client.jar. Will try with your grants and keep you posted. Thank you for your time and wisdom. Aj
You can also try to give grant only for wlthint3client.jar file:
Hello Vinish, Yes we tried that grant as well. So we started from the beginning again. All we are trying to do is invoke a Java Class from PL/SQL so that this value goes into a JMS Queue. So we took this video and followed exactly except for the weblogic jar. (video link: https://www.youtube.com/watch?v=mciJwBPIyoU) And the output I attached below. Still the error “ORA-29532: Java call terminated by uncaught Java exception: java.lang.RuntimeException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory”
Requesting your expertise. Thank you, Abhi
Hi Abhi,
I am not a Java guy, but it seems that you are missing the class in your project classpath. This error is something like class not found; that is why it cannot instantiate the class.
You have to find it how you can add this class to your classpath or in your project.
Have you provided the required privileges to your schema/user?
If not then trying executing the below commands after login as SYS user:
Replace YOURSCHEMA with your database schema.
Try this and let me know.