Java in the database – OJVM non-rolling patches – OJVM Removal

Question:

How can I find out if Oracle’s JVM is used in my database?

Answer:

This is unfortunately not as trivial as I thought initially …
Let’s start with:

Until Oracle version 11.2 or later, there was no way to confirm if Oracle JVM is not actively used in the database

However, what can be said is:
1) If there are non-Oracle schemas that contain java objects, then 3rd party products or user defined java programs could be actively using the Oracle JVM.
2) If there are Oracle schemas, other than SYS, that contain java objects, then other Oracle products or Oracle Applications could be actively using the Oracle JVM.  (For example, ORDSYS schema for Oracle Intermedia and APPS schema for Oracle Applications).
3) Even if all java objects are owned by SYS schema, there might still be user defined java objects in the SYS schema. 

If the total number of java objects owned by SYS is much greater than the totals shown above, then this is likely.  However, the totals shown above are for a fully installed Oracle JVM.  If the JVM is not fully installed, then the existence of user defined java objects in the SYS schema could still make the total number of java objects exceed the above totals. Therefore, there is no way to guarantee that the Oracle JVM is not in use.

For Oracle version 11.2 or later query the DBA_FEATURE_USAGE_STATISTICS view to confirm if the Java features are being used.

I’m not a JAVA/OJVM expert but I’d do the following:

    1. Check how many JAVA objects exist in your database:
      select owner, status, count(*) from all_objects
      where object_type like '%JAVA%' group by owner, status;
      
    2. lf the results is equal to 29211 in Oracle 12c (see MOS Note: 397770.1 for numbers in different releases) then there’s a good chance that JAVA is not in use inside the database as there are no additional user defined objects. But please consult this MOS Note for a clear understanding of the number of objects
      CLARIFICATION:
      For a minimal installation of Oracle JVM in the database (after only running initjvm.sql), the total number of valid java objects owned by SYS should look something like this.
    3. In addition you may run this script from MOS Note:456949.1 (Script to Check the Status or State of
      the JVM within the Database) to check for any user defined objects JAVA objects in your database
    4. Anyhow, before doing anything to your JAVA installation now keep in mind that there are dependencies. The following components require the existence of a valid JAVA installation in your database:
      Oracle Multimedia (formerly known as Intermedia)
      Oracle Spatial
      Oracle OLAP
      And even more important, as there are dependencies between components there may be also dependent objects belonging to these components in your database. So it’s not as simple as it looked initially – you’ll have to check if any of the dependent components is in use as well – and the numbers 4.-6. will apply to 11.2. databases only, not to Oracle 12c:

      1. How to Determine if Spatial is Being Used in the
        Database? (Doc ID 726929.1)
        Please be aware that having a user defined SPATIAL SDO Geometry object will NOT increase the number of existing Java objects compared to a default installation. Roy verified this (THANKS!). So you’ll have to make sure that you checked also the dependent components for being in use. 
      2. How To Find Out If OLAP Is Being Used (Doc ID 739032.1)
      3. How To Check If Oracle Multimedia Is Being Used In Oracle Version 11.2 (Doc ID 1088032.1)
      4. How to Determine if Ultra Search is Being Used? (Doc ID 738126.1)
      5. Warehouse builder has a note about how to uninstall it, but that (very badly written) note does not tell you how to determine whether OWB is in use
      6. Rules Manager and Expression Filter document installation and deinstallation in their developers guide
  1. And even more important, before doing anything to your JAVA installation please take a backup – even though you may believe that backups are just for wimpies you’ll better take one before 🙂
  2. Now the question is:
    Should you remove only JAVAVM component – or CATJAVA as well? Please see the section further below on this blog posting for more information.
    To remove only JAVAVM this script could do the job – but it will leave two INVALID Package Bodies (JAVAVM_SYS, JVMRJBCINV):

    SQL> @?/xdk/admin/rmxml.sql
    SQL> delete from registry$ where status='99' and cid = 'JAVAVM';
    SQL> commit;
  3. The execution of the removal scripts won’t de-register the component from DBA_REGISTRY – that’s why the manual de-registration is necessary.
  4. Even if I’d remove the entire JAVA stack including the XDK it will leave those two invalid objects  (JAVAVM_SYS, JVMRJBCINV).
    SQL> @?/rdbms/admin/catnojav.sql
    SQL> @?/xdk/admin/rmxml.sql
    SQL> @?/javavm/install/rmjvm.sql
    SQL> @?/rdbms/admin/utlrp.sql
    SQL> delete from registry$ where status='99' and cid in ('XML','JAVAVM','CATJAVA');
    

    So honestly the best choice is always not to install things you clearly don’t need instead of trying to remove those things afterwards. In this case would now need to double check with Oracle Support if we’d safely can drop the two remaining  package bodies JAVAVM_SYand JVMRJBCINV. In my environment that worked well – but obviously I can’t give any official statement here.

    Again, please don’t get me wrong:
    I don’t say that you should remove JAVA from your databases And please check back with Oracle Support before doing this. But the question came up so often in the past months because of the OJVM patch which does not allow a rolling PSU upgrade anymore. For further information please see the following MOS Note and refer to my previous post quoting one of our Java experts:

    .

    So let’s do a quick experiment.

    Check the installed components in a standard Oracle 12.1.0.2 database first:

    SQL> select substr(comp_id,1,8) COMP_ID, substr(COMP_NAME,1,36) COMP_NAME from dba_registry;
    
    COMP_ID    COMP_NAME
    ---------- ------------------------------------
    DV         Oracle Database Vault
    APEX       Oracle Application Express
    OLS        Oracle Label Security
    SDO        Spatial
    ORDIM      Oracle Multimedia
    CONTEXT    Oracle Text
    OWM        Oracle Workspace Manager
    XDB        Oracle XML Database
    CATALOG    Oracle Database Catalog Views
    CATPROC    Oracle Database Packages and Types
    JAVAVM     JServer JAVA Virtual Machine
    XML        Oracle XDK
    CATJAVA    Oracle Database Java Packages
    APS        OLAP Analytic Workspace
    XOQ        Oracle OLAP API
    RAC        Oracle Real Application Clusters

    Before we’d be able to safely remove JAVAVM we will need to take out Spatial, Multimedia and OLAP (exactly in this order) as well.

    Spatial removal: 

    SQL> drop user MDSYS cascade;
    SQL> drop user MDDATA cascade;
    SQL> drop user spatial_csw_admin_usr cascade;
    SQL> drop user spatial_wfs_admin_usr cascade;

    After this action you’ll end up with 5 invalid objects in APEX in case APEX is installed. I think you can safely ignore them as those are spatial objects in the FLOWS-APEX schema:

    PACKAGE: WWV_FLOW_SPATIAL_INT, WWV_FLOW_SPATIAL_API
    PACKAGE BODY: WWV_FLOW_SPATIAL_INT, WWV_FLOW_SPATIAL_API
    SYNONYM: APEX_SPATIAL

    Multimendia removal:

    SQL> @?/rdbms/admin/catcmprm.sql ORDIM

    OLAP removal:

    SQL> @?/olap/admin/olapidrp.plb
    SQL> @?/olap/admin/catnoxoq.sql
    SQL> @?/olap/admin/catnoaps.sql
    SQL> @?/rdbms/admin/utlrp.sql

    Let’s do the check again:

    SQL> select substr(comp_id,1,8) COMP_ID, substr(COMP_NAME,1,36) COMP_NAME from dba_registry;
    
    COMP_ID    COMP_NAME
    ---------- ------------------------------------
    DV         Oracle Database Vault
    APEX       Oracle Application Express
    OLS        Oracle Label Security
    CONTEXT    Oracle Text
    OWM        Oracle Workspace Manager
    XDB        Oracle XML Database
    CATALOG    Oracle Database Catalog Views
    CATPROC    Oracle Database Packages and Types
    JAVAVM     JServer JAVA Virtual Machine
    XML        Oracle XDK
    CATJAVA    Oracle Database Java Packages
    RAC        Oracle Real Application Clusters
    

    12 components still there – SDO, ORDIM, XQO and APS are gone as expected.

    JAVAVM removal: 

    Question would be now to remove only the JAVAVM – or CATJAVA as well?
    As of MOS Note:397770.1 it seems to be that removing the JAVAVM is (a) trivial and (b) will avoid to apply the OJVM patch. So removing JAVAVM only seems to be the best way in this case. As shown above this will lead to two additional leftover package bodies JAVAVM_SYS and JVMRJBCINV.

    4) Oracle JVM is not installed in the database

    Do not apply the DST JVM patch.

    If for some reason the patch is applied, then apply the patch to the ORACLE_HOME but DO NOT run the post install steps in the database.  This will leave unwanted java objects in the database and create an incomplete non-working Oracle JVM.  See Note 414248.1 for details.

    SQL> @?/xdk/admin/rmxml.sql
    SQL> delete from registry$ where status='99' and cid = 'JAVAVM';
    SQL> commit;

    –Mike

Share this: