Script to Check the Status or State of the JVM within the Database (Doc ID 456949.1)

To BottomTo Bottom

In this Document

  Purpose
  Requirements
  Configuring
  Instructions
  Script
  Sample Output
  References

 

Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.5 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.

*** Checked for relevance on 28-May-2019 ***

Purpose

The following script can be used to determine the status/state of the Oracle JVM component. It checks whether the component is installed completely and is in a valid/working condition or not. In addition the script will check for other required components (needed to use the Oracle JVM) and ensure that they are also installed and valid.

Requirements

The script needs to be run in SQL*Plus as a DBA.  If the database is multitenant (applicable to 12c and above) then please follow note 2347527.1: Script to Check the Status or State of the JVM within a Multi-tenant Database to generate output for every container before referring to "How to interpret the output" below.

Configuring

The script does not need any additional configuration.

Instructions

Enter the script into SQL*Plus running against an OPEN database.

Caution

This sample code is provided for educational purposes only, and is not supported by Oracle Support. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.

Script

column comp_name format a30
column version format a20
column status format a15
column owner format a30
column object_name format a30
column object_type format a15
column long_name format a75
column role format a40
column act_time format a24
column action format a15
column comments format a20

set pagesize 500
set linesize 150
set trimspool on
set serveroutput on
set echo on

spool jvm_info.log

------ REGISTRY INFO ------

SELECT SUBSTR(comp_name, 1, 30) comp_name, SUBSTR(version, 1, 20) version, status
  FROM dba_registry
 ORDER BY comp_name;

------ REGISTRY HISTORY -------

SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') act_time, action, version, id, comments
FROM dba_registry_history
ORDER BY action_time DESC;

 

------ JAVA OBJECT INFO ------

-- Are there a substantial number of VALID Java objects in SYS?

SELECT owner, object_type, status, COUNT(*)
  FROM dba_objects
 WHERE object_type LIKE '%JAVA%'
 GROUP BY owner, object_type, status
 ORDER BY owner, object_type, status;

-- Is the DBMS_JAVA package VALID?

SELECT owner, object_name, object_type, status
  FROM dba_objects
 WHERE object_name LIKE 'DBMS_JAVA%'
    OR object_name LIKE '%INITJVMAUX%'
 ORDER BY owner, object_name, object_type;

-- Are there any INVALID Java objects in SYS?

SELECT owner, NVL(longdbcs,object_name) long_name, object_type, status
  FROM dba_objects, sys.javasnm$
 WHERE object_type LIKE '%JAVA%'
   AND status <> 'VALID'
   AND short (+) = object_name
 ORDER BY owner, long_name, object_type;

------ JAVA ROLE INFO ------

-- The number expected varies by release.

SELECT role
  FROM dba_roles
 WHERE role LIKE '%JAVA%'
 ORDER BY role;

------ MEMORY INFO ------

SELECT *
  FROM v$sgastat
 WHERE pool = 'java pool' OR name = 'free memory'
 ORDER BY pool, name;

------ DATABASE PARAMETER INFO ------

show parameter pool_size

show parameter target

show parameter sga

------ TEST JAVAVM USAGE (and return the JDK version if > 11g) ------

-- Calling routines in DBMS_JAVA will invoke the JavaVM and expose certain problems.

SET SERVEROUTPUT ON
DECLARE
  ver NUMBER := 0;
  val VARCHAR2(30);
BEGIN
  BEGIN
    SELECT TO_NUMBER( SUBSTR(version, 1, 2) )
      INTO ver
      FROM dba_registry
     WHERE comp_name = 'JServer JAVA Virtual Machine';
  EXCEPTION
    WHEN OTHERS THEN NULL;
  END;

  IF ver >= 12 THEN
    EXECUTE IMMEDIATE
              'SELECT ''JDK version is '' ||
                      dbms_java.get_jdk_version() FROM dual'
            INTO val;
  ELSE
    val := dbms_java.longname('JDK version not available');
  END IF;
  dbms_output.put_line(val);
END;
/

spool off

 

Sample Output

The script will generate a log file (jvm_info.log) which can be supplied to Oracle Support Services upon request or as part of logging any Oracle JVM related Service Requests.

SQL>
SQL> ------ REGISTRY INFO ------
SQL>
SQL> SELECT SUBSTR(comp_name, 1, 30) comp_name, SUBSTR(version, 1, 20) version, status
  2    FROM dba_registry
  3   ORDER BY comp_name;

COMP_NAME                      VERSION              STATUS
------------------------------ -------------------- ---------------
JServer JAVA Virtual Machine   12.1.0.2.0           VALID
OLAP Analytic Workspace        12.1.0.2.0           VALID
Oracle Application Express     4.2.5.00.08          VALID
Oracle Database Catalog Views  12.1.0.2.0           VALID
Oracle Database Java Packages  12.1.0.2.0           VALID
Oracle Database Packages and T 12.1.0.2.0           VALID
Oracle Database Vault          12.1.0.2.0           VALID
Oracle Label Security          12.1.0.2.0           VALID
Oracle Multimedia              12.1.0.2.0           VALID
Oracle OLAP API                12.1.0.2.0           VALID
Oracle Real Application Cluste 12.1.0.2.0           OPTION OFF
Oracle Text                    12.1.0.2.0           VALID
Oracle Workspace Manager       12.1.0.2.0           VALID
Oracle XDK                     12.1.0.2.0           VALID
Oracle XML Database            12.1.0.2.0           VALID
Spatial                        12.1.0.2.0           VALID

16 rows selected.

SQL>
SQL> ------ REGISTRY HISTORY -------
SQL>
SQL> SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') action_time, action, version, id, comments
  2    FROM dba_registry_history
  3   ORDER BY action_time DESC;

no rows selected

SQL>
SQL> ------ JAVA OBJECT INFO ------
SQL>
SQL> -- Are there a substantial number of VALID Java objects in SYS?
SQL>
SQL> SELECT owner, object_type, status, COUNT(*)
  2    FROM dba_objects
  3   WHERE object_type LIKE '%JAVA%'
  4   GROUP BY owner, object_type, status
  5   ORDER BY owner, object_type, status;

OWNER                          OBJECT_TYPE      STATUS            COUNT(*)
------------------------------ ---------------  --------------- ----------
MDSYS                          JAVA CLASS       VALID                  646
MDSYS                          JAVA RESOURCE    VALID                    4
OJVMSYS                        JAVA DATA        VALID                    2
ORDSYS                         JAVA CLASS       VALID                 2490
ORDSYS                         JAVA RESOURCE    VALID                   99
SYS                            JAVA CLASS       VALID                27729
SYS                            JAVA DATA        VALID                  318
SYS                            JAVA RESOURCE    VALID                  922
SYS                            JAVA SOURCE      VALID                    3

13 rows selected.

SQL>
SQL> -- Is the DBMS_JAVA package VALID?
SQL>
SQL> SELECT owner, object_name, object_type, status
  2    FROM dba_objects
  3   WHERE object_name LIKE 'DBMS_JAVA%'
  4      OR object_name LIKE '%INITJVMAUX%'
  5   ORDER BY owner, object_name, object_type;

OWNER                          OBJECT_NAME                    OBJECT_TYPE     STATUS
------------------------------ ------------------------------ --------------- ---------------
PUBLIC                         DBMS_JAVA                      SYNONYM         VALID
PUBLIC                         DBMS_JAVA_DUMP                 SYNONYM         VALID
PUBLIC                         DBMS_JAVA_TEST                 SYNONYM         VALID
SYS                            DBMS_JAVA                      PACKAGE         VALID
SYS                            DBMS_JAVA                      PACKAGE BODY    VALID
SYS                            DBMS_JAVA_DEFINERS             PACKAGE         VALID
SYS                            DBMS_JAVA_DEFINERS             PACKAGE BODY    VALID
SYS                            DBMS_JAVA_DUMP                 PACKAGE         VALID
SYS                            DBMS_JAVA_DUMP                 PACKAGE BODY    VALID
SYS                            DBMS_JAVA_MISC                 PACKAGE         VALID
SYS                            DBMS_JAVA_MISC                 PACKAGE BODY    VALID
SYS                            DBMS_JAVA_TEST                 PACKAGE         VALID
SYS                            DBMS_JAVA_TEST                 PACKAGE BODY    VALID
SYS                            INITJVMAUX                     PACKAGE         VALID
SYS                            INITJVMAUX                     PACKAGE BODY    VALID

15 rows selected.

SQL>
SQL> -- Are there any INVALID Java objects in SYS?
SQL>
SQL> SELECT owner, NVL(longdbcs,object_name) long_name, object_type, status
  2    FROM dba_objects, sys.javasnm$
  3   WHERE object_type LIKE '%JAVA%'
  4     AND status <> 'VALID'
  5     AND short (+) = object_name
  6   ORDER BY owner, long_name, object_type;

no rows selected

SQL>
SQL> ------ JAVA ROLE INFO ------
SQL>
SQL> -- The number expected varies by release.
SQL>
SQL> SELECT role
  2    FROM dba_roles
  3   WHERE role LIKE '%JAVA%'
  4   ORDER BY role;

ROLE
----------------------------------------
JAVADEBUGPRIV
JAVAIDPRIV
JAVASYSPRIV
JAVAUSERPRIV
JAVA_ADMIN
JAVA_DEPLOY

6 rows selected.

SQL>
SQL> ------ MEMORY INFO ------
SQL>
SQL> SELECT *
  2    FROM v$sgastat
  3   WHERE pool = 'java pool' OR name = 'free memory'
  4   ORDER BY pool, name;

POOL         NAME                            BYTES     CON_ID
------------ -------------------------- ---------- ----------
java pool    JOXLE                        53750592          0
java pool    KGH: NO ACCESS                  53248          0
java pool    free memory                   4452736          0
java pool    joxs heap                      463680          0
large pool   free memory                   5242880          0
shared pool  free memory                  20183872          0

6 rows selected.

SQL>
SQL> ------ DATABASE PARAMETER INFO ------
SQL>
SQL> show parameter pool_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
global_context_pool_size             string
java_pool_size                       big integer 0
large_pool_size                      big integer 0
olap_page_pool_size                  big integer 0
shared_pool_size                     big integer 0
streams_pool_size                    big integer 0

SQL>
SQL> show parameter target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target                   integer     0
db_big_table_cache_percent_target    string      0
db_flashback_retention_target        integer     1440
fast_start_io_target                 integer     0
fast_start_mttr_target               integer     0
memory_max_target                    big integer 0
memory_target                        big integer 0
parallel_servers_target              integer     64
pga_aggregate_target                 big integer 650M
sga_target                           big integer 392M

SQL>
SQL> show parameter sga

NAME                                 TYPE         VALUE
------------------------------------ -----------  ------------------------------
lock_sga                              boolean     FALSE
pre_page_sga                          boolean     TRUE
sga_max_size                          big integer 392M
sga_target                            big integer 392M
unified_audit_sga_queue_size          integer     1048576

SQL>
SQL> ------ TEST JAVAVM USAGE (and return the JDK version if > 11g) ------
SQL>
SQL> -- Calling routines in DBMS_JAVA will invoke the JavaVM and expose certain problems.
SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2    ver NUMBER := 0;
  3    val VARCHAR2(30);
  4  BEGIN
  5    BEGIN
  6      SELECT TO_NUMBER( SUBSTR(version, 1, 2) )
  7        INTO ver
  8        FROM dba_registry
  9       WHERE comp_name = 'JServer JAVA Virtual Machine';
 10    EXCEPTION
 11      WHEN OTHERS THEN NULL;
 12    END;
 13
 14    IF ver >= 12 THEN
 15      EXECUTE IMMEDIATE
 16                'SELECT ''JDK version is '' ||
 17                        dbms_java.get_jdk_version() FROM dual'
 18              INTO val;
 19    ELSE
 20      val := dbms_java.longname('JDK version not available');
 21    END IF;
 22    dbms_output.put_line(val);
 23  END;
 24  /
JDK version is 1.6.0_71

PL/SQL procedure successfully completed.

SQL>
SQL> spool off

How to interpret the output

1) If you find entries in DBA_REGISTRY for "JServer JAVA Virtual Machine" and "Oracle Database Java Packages" then it means the Oracle JVM component is installed.

2) These two components should be in a VALID state; if not it means either they are not installed properly or something is wrong with the installation. Refer to note 2149019.1 for advice on how to resolve the problem.

3) There should be no INVALID Java objects under the SYS schema. The SYS schema contains the core Oracle JVM Java objects. If you find any invalid Java objects in this schema then you need to check whether they are part of the Oracle JVM component or are application specific classes that have inadvertently been loaded into SYS. You can try resolving invalid classes by running $ORACLE_HOME/rdbms/admin/utlrp.sql. If it does not help, or you are unsure whether an invalid Java object is a core Oracle JVM one or not, contact Oracle Support.

4) The DBMS_JAVA calls use the Oracle JVM component. If they fail with any error it means the Oracle JVM is not in an operational state. If the error is one of those discussed in note 2149046.1 then follow the steps given there. If the error code is different then contact Oracle Support for assistance.

5) The query against dba_registry_history should reflect the latest OJVM PSU that was applied. This should match that of binaries if postinstall.sql (11g) or datapatch (12c) was applied successfully.  If you receive an ORA-29548, then this likely means that opatch was run but the post install steps were not. Compare "opatch lsinventory" to determine which part (the binaries or the database instance) needs to be repaired.

 

 

References

NOTE:2314363.1 - Safe repair/reinstall of the JVM Component in 11.2 and up
NOTE:2347527.1 - Script to Check the Status or State of the JVM within a Multi-tenant Database
NOTE:397770.1 - How to Check or Verify if the Oracle JVM is Installed in the Database
NOTE:2149046.1 - ORA-29548 Java system class reported: could not identify release specified in classes.bin or ORA-29516 java.lang.UnsatisfiedLinkError sun.net.PortConfig.getLower0

posted @ 2020-11-14 21:19  耀阳居士  阅读(494)  评论(0编辑  收藏  举报