Monday Jun 22, 2015

Java in the database - OJVM non-rolling patches


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


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 I'd silently assume that JAVA is not in use inside the database as there are no additional user defined objects. 
  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
    7. .
  5. 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 :-)
  6. 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;

  7. The execution of the removal scripts won't de-register the component from DBA_REGISTRY - that's why the manual de-registration is necessary. 
  8. Even if I'd remove the entire JAVA stack including the XDK it will leave those two invalid objects  (JAVAVM_SYS, JVMRJBCINV).
    1. SQL> @?/rdbms/admin/catnojav.sql
    2. SQL> @?/xdk/admin/rmxml.sql
    3. SQL> @?/javavm/install/rmjvm.sql
    4. SQL> @?/rdbms/admin/utlrp.sql
    5. 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 database first:

SQL> select substr(comp_id,1,8) COMP_ID, substr(COMP_NAME,1,36) COMP_NAME from dba_registry;

---------- ------------------------------------
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:


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;

---------- ------------------------------------
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 

Monday Jul 04, 2011

Database Registry: Component Dependencies

Recently I had to dig a bit into the component dependency topic as I was working with an Oracle Database customer planning to upgrade to Oracle Database with a limited downtime window. To achieve the given downtime window we planned to remove some unused components from the database.

Database Component Dependencies

Example: Component Dependencies in Oracle Database 11.1

 As you know already the time it'll take to upgrade an Oracle database is mainly dependent on the number of installed components. If you'll query DBA_REGISTRY (or the underlying REGISTRY$) you'll spot all the installed (and usually configured) database components. And the more of these components are installed the longer the upgrade usually will take.

Please don't get me wrong here: This is NOT a recommendation to deinstall any components. Tomorrow or the day after somebody wishes to use some component functionality - and not nice if you have deinstalled it.

But first of all it might be a good idea to know a little bit about component dependecies - and on the other hand this might help you in one or another situations to fix INVALID components.
And please be advised: The presentation I'm refering to is not a official support note. And as it is the first release of this presentation I don't guarantee that every mentioned workaround is the best available - or will work in any environment. Please check also the referenced notes in case you'd like to "tweak" one or the other component.

You might download the presentation either via the DOWNLOAD SLIDES section in the right column of this blog (please scroll down a bit) or via this direct link here.

Database Component Dependencies Oracle 11.1
Example: Component Dependencies in Oracle Database 11.1 displayed a different way

And as always I'm happy to get your feedback :-)

Thx - Mike

P.S. Unfortunately the graphs can't be shown as animated slides in the PDF version - sorry for that, I know that the graph slides are a bit complicated ...


Mike Dietrich - Oracle Mike Dietrich
Master Product Manager - Database Upgrade & Migrations - Oracle

Based in Germany. Interlink between customers/partners and the Upgrade Development. Running workshops between Arctic and Antartica. Assisting customers in their reference projects onsite and remotely. Connect via:

- -


« November 2015
Slides Download Center
Visitors since 17-OCT-2011
White Paper and Docs
Viewlets and Videos
Workshop Map
x Oracle related Tech Blogs
This week on my Rega & Pono
Upgrade Reference Papers