Maclochlainn's Weblog

Michael McLaughlin's Old Technical Blog

A twist on a java.security.AccessControlException

with 2 comments


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

Advertisements

Written by maclochlainn

July 26, 2008 at 9:56 pm

2 Responses

Subscribe to comments with RSS.

  1. Thanks for nice and usefull article.

    Mehmet Yanki Yonel

    July 27, 2008 at 11:45 pm

  2. nice post

    cheers

    Mehmood

    November 16, 2009 at 9:21 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: