Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm trying to call a Java function from Oracle database that does the following:

Process p = Runtime.getRuntime().exec("...");

When I try to run it, I get the following error:

ORA-29532: Java call terminated by uncaught Java exception:
java.security.AccessControlException: the Permission (java.io.FilePermission
<<ALL FILES>> execute) has not been granted to SCOTT. The PL/SQL to grant this
is dbms_java.grant_permission( 'SCOTT', 'SYS:java.io.FilePermission', '<<ALL
FILES>>', 'execute' )

How do I grant this permission?


UPDATE: When I run the following in SQL*Plus (as sysdba):

dbms_java.grant_permission( 'SCOTT', 
                            'SYS:java.io.FilePermission', 
                            '<<ALL FILES>>', 
                            'execute' );

I get the error:

SP2-0734: unknown command beginning "/dbms_java..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "'SYS:java...." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "'<<ALL FIL..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
share|improve this question
2  
In order to call a stored procedure, you would either need to type EXEC before the stored procedure in SQL*Plus or surround it in a BEGIN and END block. –  Justin Cave Jun 15 '12 at 19:49

1 Answer 1

up vote 4 down vote accepted

The error message actually gives you the exact syntax

dbms_java.grant_permission( 'SCOTT', 
                            'SYS:java.io.FilePermission', 
                            '<<ALL FILES>>', 
                            'execute' )

It's not obvious to me whether you modified the text of the error message to remove a directory from the error-- normally, the error will tell you a specific directory that you need to grant access to.

If your intention is to allow the Java stored procedure to execute arbitrary shell scripts (this would be very dangerous-- the commands would run as the Oracle operating system user so they would have the ability to bypass any security measures in the database), you should be able to do something like

begin
  dbms_java.grant_permission
      ('SCOTT',
       'java.io.FilePermission',
       '<<ALL FILES>>',
       'execute');
  dbms_java.grant_permission
      ('SCOTT',
       'java.lang.RuntimePermission',
       '*',
       'writeFileDescriptor' );
end;
share|improve this answer
    
Nope, I didn't modify it at all. I'm assuming it's because there's no exact file, it's running a shell script. –  notfed Jun 15 '12 at 19:43
    
This didn't work for me. I've updated my question to show the error I'm getting. –  notfed Jun 15 '12 at 19:46
1  
@notfed - I updated my answer with an example. If you're calling shell scripts, you'll also likely need the RuntimePermission. –  Justin Cave Jun 15 '12 at 19:53
    
Actually I just need to run a specific shell script, so I assume I just change <<ALL FILES>> to the pat of this script. Thanks. –  notfed Jun 15 '12 at 19:54
    
@notfed - Yes. If you can lock it down to one script, that would be much safer –  Justin Cave Jun 15 '12 at 19:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.