A twist on a java.security.AccessControlException
A twist or quirk, I’m not sure. I was working on a internal Java library to delete external files when I encountered an ORA-29532. The error said that I needed to grant read file permissions but it really required read, write, and delete permissions. Worse yet, they’d already been granted.
Then, I remembered that this is the instance that I built before assigning a hostname in the C:\WINDOWS\system32\drivers\etc\hosts file. I’d blogged about it earlier, describing how to drop and recreate the Enterprise Manager. I had a hunch, and it worked.
I ran the following:
BEGIN
DBMS_JAVA.GRANT_PERMISSION('SYSTEM'
,'SYS:java.net.SocketPermission'
,'hostname:1521'
,'connect,resolve');
END;
/
Then, I reconnected as the test user and everything worked fine. The full error received:
BEGIN delete_file(get_canonical_local_bfilename(:locator));
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.security.AccessControlException: the Permission (java.io.FilePermission
C:\JavaDev\BFileFramework\HarryPotter1.png read) has not been granted to PLSQL.
The PL/SQL to grant this is
dbms_java.grant_permission( 'PLSQL',
'SYS:java.io.FilePermission', 'C:\JavaDev\BFileFramework\HarryPotter1.png','read' )
ORA-06512: at "PLSQL.DELETE_FILE", line 1
ORA-06512: at line 1
You can get the full Java stack trace by two steps:
1. Call the DBMS_JAVA.SET_OUTPUT(2000000);
2. Set SERVEROUTPUT ON
Thanks for nice and usefull article.
Mehmet Yanki Yonel
July 27, 2008 at 11:45 pm