6 Replies Latest reply: Jun 5, 2011 8:00 PM by 866358 RSS

    RMI-Problem

    505303
      Hi there,
      I have the following Situation:
      I want to call an RMI server from an ORACLE10G Database. The RmiServer runs on JVM1.5.
      The Code for the client looks like this:
      package com.HP.RFID.JavaStoredProcedures;
      import com.HP.RFID.SendIncommingEdgeEvent.SendIncommingEvent;
      import java.rmi.Naming;
      import java.rmi.RMISecurityManager;
      import java.rmi.registry.LocateRegistry;
      import java.rmi.registry.Registry;
      public class CallRmiServer {
      public static String callRmiServer( String device, int msgNumber, int msgSubType, String data ) {
      String result = "OK";
      try{
      if (System.getSecurityManager() == null){
      System.setSecurityManager(new RMISecurityManager());
      }
      SendIncommingEvent event = (SendIncommingEvent)Naming.lookup("rmi://15.136.25.58/RfidRmiServer");
      event.sendEvent(device,msgNumber,msgSubType,data);
      } catch (Exception e) {
      e.printStackTrace();
      result = e.toString();
      }
      return result;
      }
      }
      When i call this Class then i get the following Exception:
      java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.lang.ClassNotFoundException: java.rmi.server.RemoteObjectInvocationHandler
      at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
      at java.rmi.Naming.lookup(Naming.java:84)
      at com.HP.RFID.JavaStoredProcedures.CallRmiServer.callRmiServer(CallRmiServer.java:17)
      Caused by: java.lang.ClassNotFoundException: java.rmi.server.RemoteObjectInvocationHandler
      at java.net.URLClassLoader$1.run(URLClassLoader.java:214)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:196)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:243)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:430)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
      at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
      at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
      at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:205)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      ... 3 more
      I gave the required permissions with the following calls:
      exec dbms_java.grant_permission('EDGE',
      'SYS:java.net.SocketPermission','*','resolve');
      exec dbms_java.grant_permission('EDGE',
      'SYS:java.net.SocketPermission','*','connect');

      The SendEventImpl_Stub.class is also uploadet to the database...
      Has anybody an Idea what is wrong?
        • 1. Re: RMI-Problem
          Avi Abrami
          user502300,
          I'm only guessing, but it's probably because your RMI server is JDK 1.5 while the Oracle database JDK is 1.4

          Did you try using JDK 1.4 for your RMI server?

          Good Luck,
          Avi.
          • 2. Re: RMI-Problem
            505303
            I've also tried to use the JVM1.4 but that changes absolute nothing in the Errormessage...

            Jan
            • 3. Re: RMI-Problem
              Avi Abrami
              Jan,
              All I can tell you is, I managed to do this with Oracle 8i (8.1.7) and JDK 1.3, several years ago. And it worked no problem. We ended up not using this, so I don't have the code any more and I don't really have the time to try and reproduce it for you now. Sorry :-(

              I just remember that you don't really need the "SecurityManager".

              An alternative is to use servlets in a Web server (instead of RMI server). Or perhaps EJB, since Oracle 10g database claims to support EJB callout.

              Good Luck,
              Avi.
              • 4. Re: RMI-Problem
                505303
                Hi,
                I solved it in the meanwhile too. The EJB callout was my first attempt, but its impossible to call an OC4J Server because of missing dependency in the Database. (So I needet RMI-Connection as an bridge for the EJB Calls).The Problem was that the JDevelloper claimed to compile with JDK 1.4 but used the 1.5. So after handcompiling eveything with 1.4 everything went fine.
                Greetings
                Jan
                • 5. Re: RMI-Problem
                  Kmensah-Oracle
                  Hi,

                  I am glad that you solved your problem using JDK 1.4 as Avihas indicated.
                  Regarding EJB Callout, it indeed works in 10g database, you need to alter a bit the EJB client, give it thwe appropriate permissions, and so on. The complete stepby step and the required changes are described in my just-released book @ http://www.amazon.com/gp/product/1555583296/

                  Kuassi, http://db360.blogspot.com/
                  • 6. Re: RMI-Problem
                    866358
                    Hi Jan,

                    Even I'm facing the same problem. Could you please eloborate your solution. I'm getting this problem (java.lang.classnotfoundexception java.rmi.server.remoteobjectinvocationhandler) when the RMI Server is 1.5 and RMI client is 1.4. If I upgrade the client to JDK 1.5, it is working fine. Could you let me know the solution.

                    Thanks,
                    Murali