Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Load Java classes

Re: Load Java classes

From: Vladimir M. Zakharychev <vladimir.zakharychev_at_gmail.com>
Date: 6 Dec 2006 13:13:49 -0800
Message-ID: <1165439629.586372.39300@79g2000cws.googlegroups.com>

devjnr_at_gmail.com wrote:
> I imported some java classes this way:
>
> loadjava -user system/oracle_at_ORCL "C:\lib\core.jar"
>
> ..
>
> I'm trying to write a java source that use these classes but when I try
> to compile I obtain this error:
>
> Error: cannot access core.class1
>
> I googled a little and I found that perhaps I also should give
> permissions...
>
> exec dbms_java.grant_permission('SYSTEM', 'core', '*', 'read,write');
>
> When I try to run this code:
>
> ORA-29532: Java call terminated by uncaught Java exception:
> java.lang.ClassNotFoundException: core
>
> It is strange behavior, isn't it?
>
> Any help appreciated.

No, the behavior is totally predictable. :) You indeed need to give permissions, just not this kind of permissions. You need to grant EXECUTE privilege on SYSTEM.core.* classes to the user or role that will be calling them. You can do it during class load phase with -g[rant] switch:

loadjava -user system/password_at_dbalias -g WHOEVER,SOMEROLE c:\lib\core.jar

(note: there should be no spaces in comma-separated list of grantees.)

I wouldn't use SYSTEM account for this either, though it won't break anything if you do - Java classes are loaded with invoker rights by default, so they will not inherit SYSTEM privileges when executed by some other user. Nevertheless, if possible, create another account with limited privileges (CREATE SESSION, CREATE TABLE and CREATE PROCEDURE should be sufficient,) and load your classes into this schema. CREATE TABLE is necessary because loadjava automatically creates a couple of tables in the target schema for temporary class file storage and integrity verification and will probably fail if it won't be able to create them. CREATE SESSION may be revoked or account may be locked after the load.

Hth,

    Vladimir M. Zakharychev
    N-Networks, makers of Dynamic PSP(tm)     http://www.dynamicpsp.com Received on Wed Dec 06 2006 - 15:13:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US