Thursday, February 02, 2012

dbms_java.grant_permission - java.lang.RuntimePermission setIO

Java runtime execution permission needs to be granted to a application user that using  java access control. DBA_JAVA_POLICY is the DBA view that shows us which users has what kind of permissions. 
A typical application error which is self explanatory:
Result is: java.security.AccessControlException: the Permission (java.lang.RuntimePermission setIO) has not been granted to DB_USER. The PL/SQL to grant this is dbms_java.grant_permission( 'DB_USER', 'SYS:java.lang.RuntimePermission', 'setIO', '' ) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:275)
               at java.security.AccessController.checkPermission(AccessController.java:456)
               at java.lang.SecurityManager.checkPermission(SecurityManager.java:534)
               at oracle.aurora.rdbms.SecurityManagerImpl.checkPermission(SecurityManagerImpl.java:204)
               at java.lang.System.checkIO(System.java:214)
               at java.lang.System.setOut(System.java:154)
               at com.testing.duplicate.AutoQuoteDuplicator.updateDuplicate(AutoQuoteDuplicator.java:69)
               at com.testing.duplicate.AutoQuoteDuplicator.processDuplicateRequest(AutoQuoteDuplicator.java:381)

Here is how we give permission:

execute dbms_java.grant_permission( DB_USER, 'SYS:java.lang.RuntimePermission', 'setIO', '' )

No comments: