简体   繁体   中英

dbms_java.grant_permission is required for every new session

i am trying to implement java RMI client server connection, i made my server in NetBeans IDE and client class made in oracle database as java store procedure and use this via oracle function in my PLSQL block, everything is working fine but I stuck in little issue below:

I made this java store procedure in SYSTEM user and give dbms_java.grant_permission('SYSTEM','java.net.SocketPermission','192.168.43.25:*','connect,resolve') to SYSTEM user via SYSDBA, "*" is used for all available ports. I get perfect response from my server but till specific session expiry.

Whenever I logout from SYSTEM user and login back again, its again throws me an exception the Permission ("java.net.SocketPermission" "192.168.43.25:56792" "connect,resolve") has not been granted please guide me how can I get rid from this repeated task? because in development environment I'll manage it but how can deploy it on production with this issue. My Environment is Oracle DB 18c XE, Thank You!

Following is my java store procedure:

create or replace and compile java source named rmi as
package rmi;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.security.Policy;




 public class RmiClient {

    public RmiClient(){
    }

    public static String getRequestFromClient(){
        Policy.setPolicy(new MyPolicy());
        String result = "";
        try {
            IServer server = getServer();
            result = server.getRequestFromClient();
        } catch (Exception ex) {
            result = ex.getMessage().toString();
        }
        return result;

    }
    private static IServer getServer() throws Exception {
        Parameter configurationParameters = new Parameter();
        IServer server = (IServer) Naming.lookup( configurationParameters.objectName);

        return server;
    }
    }

Granting permissions with DBMS_JAVA is a little different than a typical Oracle grant. After granting a permission using DBMS_JAVA.GRANT_PERMISSION , you will need to COMMIT at some point after the grant as been executed for it to take affect permanently. Notice how there is a COMMIT after the DBMS_JAVA call in the Oracle documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM