• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Permission problem calling java from PL/SQL

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
}
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tony,
Try using "RIMS" (and not "rims"), as in:

Good Luck,
Avi.
 
Tony Evans
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Avi, I needed my DBA to set my java permissions.

Tony
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic