cannot drop jar from Oracle database with dropjava command

cannot drop jar from Oracle database with dropjava command



I am trying to execute dropjava command to drop a jar file in the database....


dropjava -u username/password@schema -v -r abc.jar



... but it is giving me the following error:


ORA-29537: class or resource cannot be created or dropped directly



What is the problem?



I loaded the JAR using this command:


loadjava -u username/password@schema -v -r -f abc.jar





What was the precise command (including options) you used to load the jar into the database? What is the precise set of options you're using with dropjava?
– APC
Jul 10 '12 at 12:44


dropjava





The exact command is: dropjava -u username/password@schema -v -r abc.jar
– mkbsc
Jul 10 '12 at 13:06





Yes but did you use any other options when you loaded teh jar?
– APC
Jul 10 '12 at 14:37





to load the jar i've used the following command: loadjava -u username/password@schema -v -r -f abc.jar
– mkbsc
Jul 11 '12 at 5:36





3 Answers
3



TL;DR: An java source object (object_type='JAVA SOURCE') which defines the same class already exists in the database. Drop it first.


object_type='JAVA SOURCE'


$ oerr ora 29537



29537, 00000, "class or resource cannot be created or dropped directly"

// *Cause: An attempt was made to create or drop a Java class or resource that

// is known to result from compilation of an existing Java source object.

// *Action: Act on the class or resource by acting on the source, or change

// the source so that it no longer defines the class or resource.



Consider the following MCVE:


$ echo "public class SomeClass " >SomeClass.java
$ javac SomeClass.java
$ jar -cvf SomeClass.jar SomeClass.class
$ conndb="user/pass@db_server/sevice_name"

$ loadjava -u $conndb -r -v SomeClass.jar
resolving: class SomeClass
Classes Loaded: 1

$ dropjava -u $conndb -v SomeClass.jar
dropping: class SomeClass



So far, so good. Now, let's create the java source object that defines the same class:


$ sqlplus -l -s $conndb <<+++
create or replace and compile java source named "SomeClass" as
$(<SomeClass.java)
/
+++
Java created.



Then the class can be neither created nor dropped directly:


$ loadjava -u $conndb -r -v SomeClass.jar
Error while creating class SomeClass
ORA-29537: class or resource cannot be created or dropped directly

$ dropjava -u $conndb -v SomeClass.jar
Error while dropping SomeClass
ORA-29537: class or resource cannot be created or dropped directly



Drop the existing java source that defines class with the same name and it'll work again:


$ sqlplus -l -s $conndb <<+++
drop java source SomeClass;
+++
Java dropped.

$ loadjava -u $conndb -r -v SomeClass.jar
resolving: class SomeClass
Classes Loaded: 1

$ dropjava -u $conndb -v SomeClass.jar
dropping: class SomeClass



This is basically a guess but I think it is worth a shot.



Connect to your database as the appropriate user and trying dropping the JAR with the PL/SQL package DBMS_JAVA. In SQL*Plus that would look likeL


dbms_java.dropjava('-jarsasdbobjects abc.jar');



The PL/SQL takes the same options as the dropjava commandline.


dropjava





not working for me , getting not found , i mean not found the jar i am trying to drop which was loaded by loadjava
– Forhad
Nov 20 '13 at 6:00



This command works, I think:


dropjava -u username/password@schema -v -r -f abc.jar



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế