While granting permission to a user using dbms_java PL/SQL package of Oracle it fails with ORA-29532: like below.
SQL> exec dbms_java.grant_permission( 'arju', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' ); BEGIN dbms_java.grant_permission( 'arju', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' ); END; * ERROR at line 1: ORA-29532: Java call terminated by uncaught Java exception: oracle.aurora.vm.IdNotFoundException: -1 is not the number of a user or role ORA-06512: at "SYS.DBMS_JAVA", line 313 ORA-06512: at line 1
Cause of the Problem
In the package DBMS_JAVA, the first parameter of grant_permission subprogram is Grantee which is the name of the user, schema, or role to which you want the grant to apply. PUBLIC specifies that the row applies to all users.
The error occurred as the user name does not exist in the database. Whenever we put any name in SQL*plus without quote Sql*plus interprets it into uppercase. Our username also in this case uppercase and so it was needed to put the parameter in uppercase.
Note that here even User ID will not work.
For example:
SQL> select user_id from dba_users where username='ARJU';
USER_ID
----------
62
SQL> exec dbms_java.grant_permission( '62', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' );
BEGIN dbms_java.grant_permission( '62', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' ); END;
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
oracle.aurora.vm.IdNotFoundException: -1 is not the number of a user or role
ORA-06512: at "SYS.DBMS_JAVA", line 313
ORA-06512: at line 1
Solution of the Problem
Correct the grantee name. Here I put it into uppercase and it solved the problem.
SQL> exec dbms_java.grant_permission( 'ARJU', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' ); PL/SQL procedure successfully completed.