Link to home
Start Free TrialLog in
Avatar of khzuul
khzuul

asked on

RMI AND SSL: java.lang.ClassCastException: $Proxy0

I'm tryiong to run this simple code:

Main.java

>import java.rmi.registry.LocateRegistry;
>import java.rmi.registry.Registry;
>import java.rmi.server.RMIClientSocketFactory;
>import java.rmi.server.RMIServerSocketFactory;
>import java.rmi.server.UnicastRemoteObject;
>
>import javax.rmi.ssl.SslRMIClientSocketFactory;
>import javax.rmi.ssl.SslRMIServerSocketFactory;
>
>public class Main{
>
>      /**
>       * @param args
>       */
>      public static void main(String[] args) {
>            try{
>
>            RemoteObject ro = new RemoteObject();
>          
>            RMIClientSocketFactory csf = new SslRMIClientSocketFactory();
>              RMIServerSocketFactory ssf = new SslRMIServerSocketFactory();
>          
>                  RemoteObject serverStub =(RemoteObject) UnicastRemoteObject.exportObject(ro, 1099, csf, ssf);
>              // create the registry and bind the name and object.
>             Registry registry = LocateRegistry.createRegistry( 2004 );
>                    
>              registry.rebind("remoteObject", serverStub);
>      
>            }catch (Exception e) {
>                  e.printStackTrace();
>            }
>
>      }

The RemoteObject.file has the following code:

>public class RemoteObject implements RemoteObjectInterface{
>
>    public void receiveMessage(String message) throws Exception{
>      System.out.println("Remote: Recieved a message: \"" + message +"\"" );
>    }
>
>}

And the interface code is


>import java.rmi.*;
>import java.util.Vector;
>
>
>public interface RemoteObjectInterface extends Remote{
>
>      public void receiveMessage(String x) throws Exception;
>
>}

I get this exception:

java.lang.ClassCastException: $Proxy0
      at Main.main(Main.java:23)

I really can't understand what it's related to, i'm using JVM v 5.0.

Please it's VERY urgent
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial