Oracle11g的JDBC驱动遭遇WARNING: Error while registering Oracle JDBC Diagnosability MBean.

今天白珏的信雅达影像系统迁移到11g数据库时,他们有个应用启动初始化JDBC数据源时总是出现下面的错误:

Oct 17, 2012 4:46:45 PM oracle.jdbc.driver.OracleDriver registerMBeans

WARNING: Error while registering Oracle JDBC Diagnosability MBean.

java.security.AccessControlException: Access denied (javax.management.MBeanTrustPermission register)

        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:157)

        at java.lang.SecurityManager.checkPermission(SecurityManager.java:594)

        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1742)

        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:353)

        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:515)

        at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:360)

        at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:199)

        at java.security.AccessController.doPrivileged(AccessController.java:197)

        at oracle.jdbc.driver.OracleDriver.(OracleDriver.java:195)

        at java.lang.J9VMInternals.initializeImpl(Native Method)

        at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)

        at java.lang.Class.forNameImpl(Native Method)

        at java.lang.Class.forName(Class.java:130)

        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)

        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

        at I.C.getConnection(XUBL)

        at com.sunyard.sunflow.db.pool.ConnectionManager.getConnection(XUBL)

        at com.sunyard.sunflow.db.pool.ConnectionManager.init(XUBL)

        at com.sunyard.sunflow.SunflowEngine.XUBL(XUBL)

        at com.sunyard.sunflow.SunflowEngine.main(XUBL)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:618)

        at com.sunyard.sunflow.tool.EngineStartor.main(EngineStartor.java:114)

之前用他们使用的jdbc driver的版本是ojdbc4.jar,现在换成11g的数据库后相应的把jdbc driver换成ojdbc5.jar,但是使用新的驱动程序总是会出现上面的问题,只要换回老的驱动就一切OK。

重点关注一下错误信息中的Access denied字眼,说明这应该是新版jdbc驱动中的某种访问策略拒绝的问题。在MOS找到一篇与之相同的文章,果然需要修改java的策略文件$JAVA_HOME/jre/lib/security/java.policy,照着文档在java.policy文件中添加如下内容后再次启动就OK了:

// JMX Java Management eXtensions

permission javax.management.MBeanTrustPermission"register";

 

 

" Error while registering Oracle JDBC Diagnosability MBean. java.security.AccessControlException: access denied (javax.management.MBeanTrustPermission register) " When Using JDBC Driver 11g [ID 1229803.1]

转到底部


修改时间: 2012-4-30 类型: PROBLEM 状态:MODERATED 优先级:3

注释 (0)

In thisDocument

Symptoms

 

Changes

 

Cause

 

Solution


This document is being delivered to youvia Oracle Support's Rapid Visibility (RaV) process and therefore has not beensubject to an independent technical review.

Appliesto:

JDBC - Version 11.1.0.7 and later
Information in this document applies to any platform.
***Checked for relevance on 30-Apr-2012*** 

Symptoms

When running a job from Weblogic application, the followingmessage is displayed:


Sep 21, 2010 11:46:35 AM oracle.jdbc.driver.OracleDriver registerMBeans
WARNING: Error while registering Oracle JDBCDiagnosability MBean.
java.security.AccessControlException: accessdenied (javax.management.MBeanTrustPermission register)


The issue does not occur with JDBC 10.2.0.2; occurs with JDBC 11.1.0.7 and 11.2.0.1.

Changes

JDBC driver was upgraded from 10.2.0.2 to 11.1.0.7
JDK was upgraded to 1.6 from 1.5.

Cause


This issue is caused by missing permissionjavax.management.MBeanTrustPermission "register".

In 11g the driver registers an MBean. It did not in 10g.
The driver registers the MBean using the standard Java APIs. Those APIs requirethe permission. In order to run correctly the driver code base requires thispermission. Without the permission the driver does not run correctly.

Solution

Include the permissionjavax.management.MBeanTrustPermission "register" in the securitypolicy file /opt/apps/java/jdk160_20/jre/lib/security/java.policy:

grant {
// JMX Java Management eXtensions
permissionjavax.management.MBeanTrustPermission "register";
};


In order to run correctly the driver code base requires this permission. 

If the JRE is shared by different applications, and you only require it for aparticular application, specify an additional policy file when invokingexecution of this application. 
This can be done via the "-Djava.security.policy" command lineargument, which sets the value of the java.security.policy property. Forexample, if you use


-Djava.security.policy=someURL

for some application, where someURL is a URL specifying the location of apolicy file, then the specified policy file will be loaded in addition to allthe policy files that are specified in the security properties file.

If you use: 


-Djava.security.policy==someURL

(note the double equals) then just the specified policy file will be used; allthe ones indicated in the security properties file will be ignored.

More information on this can be found at:
http://download.oracle.com/javase/6/docs/technotes/guides/security/PolicyFiles.html
Section: Specifying an Additional Policy File at Runtime.

 

 

你可能感兴趣的:(Oracle,Error,Oracle,Java,WAS,Develop,WebLogic)