How to Perform a Non-Default Oracle JVM Re-installation

Introduction to Oracle JVM Re-installation

If the currently installed JVM in the database has a problem, a supported JVM re-installation would involve running rmjvm.sql and initjvm.sql but this would remove ALL Java objects in the database.

The steps in this post will remove and re-install the CORE JVM while leaving all the user defined Java objects

The actions performed make direct changes to the underlying data dictionary tables, which should not be attempted without the guidance of Oracle Support Services.

For Oracle Real Application Cluster (RAC) ,we  should ensure that all nodes of the cluster are shutdown except the master node, and perform these actions on the master node only

We should perform a full backup of database before performing the action item here

How to Perform a Non-Default Oracle JVM Re-installation

Step 1  Removal of system level objects of JVM

connect / as sysdba
spool rmcorejvm.log
set echo on
set serveroutput on
select owner, status, count(*) from all_objects
where object_type like ‘%JAVA%’ group by owner, status;
execute rmjvm.run(false);
shutdown immediate
set echo off
spool off
exit

Check for any errors in the spool log

Step 2  Recreate of system level objects of JVM

connect / as sysdba
spool corejvminst.log
set serveroutput on
set echo on
startup mount
alter system set “_system_trig_enabled” = false scope=memory;
alter database open;
select owner, status, count(*) from all_objects
where object_type like ‘%JAVA%’ group by owner, status;
create or replace java system
/
shutdown immediate
set echo off
spool off
exit

Step 3 Post compilation and validation

a)  Restart the database and resolve any invalid java objects

connect / as sysdba
startup
select owner, status, count(*) from all_objects where object_type like ‘%JAVA%’ group by owner, status;
b) Check for invalid

col object_name format a50
col owner format a10
set lines 300
set pages 1000
select object_name,
object_type,
owner,
status
from dba_objects
where status = ‘INVALID’
/

If present, compile them

@?/rdbms/admin/utlrp.sql

 

c) select owner, status, count(*) from all_objects where object_type like ‘%JAVA%’ group by owner, status;

Important Note
The core JVM objects should now be fully re-installed. The count of Java objects owned by the SYS user should be the same as before the re-installation.

If the count of java objects for the SYS user is greater than before, it means some objects were missing originally. If the count is less than before, it means some objects owned by SYS user were actually user defined objects and they will be LOST.