• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Permission problem calling java from PL/SQL

 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run my store procedure


CREATE OR REPLACE PACKAGE BODY confirms_write_to_file
AS

FUNCTION translate(in_en_var in VARCHAR2)
RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'translate.translatePath(java.lang.String) return java.lang.String';

PROCEDURE write_to_file(in_file_name IN VARCHAR, in_en_var IN VARCHAR)
IS
file_handleUTL_FILE.FILE_TYPE;
file_location VARCHAR2(50);

BEGIN

file_location := translate(in_en_var);
dbms_output.put_line ('opened file location' ||file_location);



END write_to_file;

END confirms_write_to_file;
/

I get the following error:

exec confirms_write_to_file.write_to_file('zzzz','$RIMS_LOG');

SQL> exec confirms_write_to_file.write_to_file('zzzz','$RIMS_LOG');
Exception java.security.AccessControlException: the Permission
(java.io.FilePermission <<ALL FILES>> execute) has not been granted by
dbms_java.grant_permission to
SchemaProtectionDomain(RIMS|PolicyTableProxy(RIMS))
opened file locationProcess problem

PL/SQL procedure successfully completed.

When I try to to grant myself the permissions

begin
dbms_java.grant_permission('rims','java.io.FilePermission','*','execute');
dbms_java.grant_permission('rims', 'java.lang.RuntimePermission', '*','writeFileDescriptor' );
end;

I get the following Error:

oracle.aurora.vm.IdNotFoundException: rims is not a user or role
at oracle.aurora.rdbms.DbmsRealm.getId(DbmsRealm.java)
at oracle.aurora.rdbms.DbmsRealm.getId(DbmsRealm.java)
at
oracle.aurora.rdbms.security.PolicyTableManager.findAll(PolicyTableManager.java)
at oracle.aurora.rdbms.security.PolicyTableManager.find(PolicyTableManager.java)
at
oracle.aurora.rdbms.security.PolicyTableManager.activate(PolicyTableManager.java
)
at
oracle.aurora.rdbms.security.PolicyTableManager.grant(PolicyTableManager.java)
begin
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
oracle.aurora.vm.IdNotFoundException: rims is not a user or role
ORA-06512: at "SYS.DBMS_JAVA", line 0
ORA-06512: at line 2


My java code is as follows

import java.io.*;
import java.util.*;

class translate
{
public static String translatePath(String envar)
{
Runtime rt = Runtime.getRuntime();
int bufSize = 4096;
byte buffer[] = new byte[bufSize];
String path = null;
Process p = null;

int len = 0;

try
{
p = rt.exec("echo "+envar);

BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
while ((len = bis.read(buffer, 0, bufSize)) != -1)
{
System.out.write(buffer, 0, len);
}
path = new String(buffer);
p.waitFor();
}
catch(Exception e)
{
System.out.println("Exception "+e);
return "Process problem ";
}
return path;
}
}
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony,
Try using "RIMS" (and not "rims"), as in:

Good Luck,
Avi.
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Avi, I needed my DBA to set my java permissions.

Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic