2

I tried to load some jars into my database, but I think I messed up something, because I tried as DBA and then with some oracle user... This was my first command:

call dbms_java.loadjava('-genmissing -jarasresource -v -force -grant MYSCHEMA ./some-jar-file.jar');

and then this:

call dbms_java.loadjava('-genmissing -v -force -grant MYSCHEMA ./some-jar-file.jar');

I think I also tried with and without MYSCHEMA, because my Java source had alway some errors regarding to this jars.

My problem is, that right now I have more than 1500 invalid Java classes and I don't know how to clean this mess up:

SELECT *
    FROM user_objects
    WHERE /*object_type like '%JAVA%'
    AND */status = 'INVALID'

I tried with this trick:

SET HEADING OFF SET FEEDBACK OFF SET ECHO OFF;

SPOOL delete-java-class.sql;

select 'drop java class "'||object_name||'";' from user_objects where object_type like '%JAVA%' AND status = 'INVALID';

SPOOL OFF;

SET HEADING OFF SET FEEDBACK OFF SET ECHO OFF;

SPOOL compile-java-class.sql;

select 'alter java class "'||object_name||'" resolve;' from user_objects where object_type like '%JAVA%' AND status = 'INVALID';

SPOOL OFF;

But the drop script wasn't able to drop these classes (approx. 5 of 1500 could be deleted), I got this error:

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

The recompile script was also not able to resolve the issue, but it was able to reduce the invalid count to 800.

Can someone give me some advice? :) Thank you.

5
  • Have you tried using the dropjava procedure in DBMS_JAVA?
    – andba77
    Sep 4, 2015 at 14:39
  • Yes, I executed the call dbms_java.dropjava() for every .jar with schema option, without, as -jarasresource as -jarsasdbobjects, but the invalid classes are still there
    – VORiAND
    Sep 4, 2015 at 14:53
  • It looks like there's also a command-line version which you can run from the operating system. Have you tried that? docs.oracle.com/cd/E11882_01/java.112/e10588/…
    – andba77
    Sep 4, 2015 at 19:00
  • Why would the command line version of dropjava behave differently... ? But I will give it a try, thank you.
    – VORiAND
    Sep 6, 2015 at 20:27
  • It's the same. It's seems, that some of the jars are stuck or something like this, because the invalid java object count doesn't want to change :(
    – VORiAND
    Sep 7, 2015 at 14:49

1 Answer 1

0

drop java class <class_name>

If you have more than one invalid class, you could edit this script I wrote, changing the owner, to spool a file that you can then run. To spool the output, at the SQL*Plus prompt do:

spool dropit.sql;
select 'drop java class '||'"'||object_name||'"'||';' 
from dba_objects where object_type='JAVA CLASS' and status='INVALID' 
and owner='SCHEMA-OWNER';

Where dropit.sql is the filename containing your drop script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.