Skip to Main Content
  • Questions
  • ORA-65040 when loading jar file into pluggable database with sys.dbms_java.loadjava or commandline tool loadjava

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sigrid.

Asked: April 14, 2021 - 3:02 pm UTC

Last updated: June 01, 2021 - 1:47 am UTC

Version: 19.8

Viewed 1000+ times

You Asked

I want to load a jar file into the database. First I loaded it into the root container.

loadjava -o -f -noverify -synonym -stdout -verbose -recursivejars -resolve -grant PUBLIC -user sys/password@CDB javax.mail.jar >\mail.log

This also works, but I don't have access to it in the PDB.

Trying to load the jarfile into the PDB fails with the error ORA-65040: operation not allowed from within a pluggable database. The same message comes when I use dbms_java.loadjava('-v -r -g PUBLIC /path/java/javax.mail.jar'); after switching into the PDB.

How can I load jarfiles into a PDB or make them available there?

Thanks for help

Sigrid

and Connor said...

Can you try this:

connect sys/syspwd@mypdb as sysdba
alter session set "_ORACLE_SCRIPT"=true;
call dbms_java.loadjava('-v -r -g PUBLIC /path/java/javax.mail.jar');


and see how that goes. But if you're looking at running mail from the database, I'd recommend using APEX_MAIL instead. Easier and more flexible.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Sigrid, April 15, 2021 - 3:35 pm UTC

Thank you Connor for answering my question. I have tried the suggested method in two different PDB's from different container databases.

Case 1
CDB1: jar file was not loaded first in the root container.
PDB1 on CDB1: the jarfile was loaded into the PDB1 using the suggested method with no errors. It works fine.

Case 2
CDB2: jar file was loaded first in the root container without errors. All Java Sources are valid there.
PDB2 on CDB2: brings the following error when I try to import the jar file there with the suggested method.

SQL> connect sys/xxx@pdb2 as sysdba
SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 PDB2 READ WRITE NO
SQL> alter session set "_ORACLE_SCRIPT"=true;
SQL> call dbms_java.loadjava('-v -r -g PUBLIC /home/oracle/downloads/java/javax.mail.jar');
call dbms_java.loadjava('-v -r -g PUBLIC /home/oracle/downloads/java/javax.mail.jar')
*
Error at Line 1:
ORA-00604: error occurred at recursive sql level 1
ORA-04020: deadlock detected while trying to lock object
SYS.javax/mail/internet/InternetHeaders$InternetHeader

How can I solve the problem for PDB2?
Connor McDonald
April 19, 2021 - 5:33 am UTC

That sounds like some sort of name clash, but you shouldn't be seeing 4020.

I think its time you need to get in touch with Support to potentially raise a bug.


Sigrid, April 19, 2021 - 8:34 am UTC

Thanks for the feedback. I have since run the call again with the -force option. This was executed without error message.
However, I had the problem that various public synonyms for the java sources were not created. I have now corrected this manually, so that it works at the moment.
Connor McDonald
June 01, 2021 - 1:47 am UTC

Nice work. Thanks for getting back to us

More to Explore

Multitenant

Need more information on Multitenant? Check out the Multitenant docs for the Oracle Database