Announcement Announcement Module
Collapse
No announcement yet.
SPring based RMI service + Plain old RMI Client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SPring based RMI service + Plain old RMI Client

    Is spring based RMI server compatible with a simple RMI client (plain old RMI client - not spring based) ?
    I have been trying to get this combination working. But no luck. Does the RMI client has to be spring based too ?

    Server side xml configuration -

    <bean class="org.springframework.remoting.rmi.RmiService Exporter">
    <property name="serviceName" value="remoteJournalOperationServiceNm"/>
    <property name="service" ref="remoteJournalOperationService"/>
    <property name="serviceInterface" value="com.ubs.pb.cts.services.client.JorunalOpera tions"/>
    <property name="registryPort" value="${rmi.remoteSvc.port}"/>
    </bean>

    <bean id="remoteJournalOperationService" class="com.ubs.pb.cts.services.client.JorunalOpera tionsImpl"></bean>

    Client side -

    static public void main(String args[])
    {
    Object rmiServer; //=> Need this to be defined as JorunalOperations -
    Registry registry;
    String serverAddress="localhost";
    String serverPort="1234";
    System.out.println("sending to "+serverAddress+":"+serverPort);
    try{
    // get the
    registry=LocateRegistry.getRegistry(serverAddress, (new Integer(serverPort)).intValue());

    //=>>> look up the remote object as JorunalOperations - but throws ClassCastException here -
    rmiServer=(registry.lookup("remoteJournalOperation ServiceNm"));
    System.out.println("Successfully connected");
    // call the remote method
    rmiServer.cancelJournal(1234, 1, "Makarand");
    }
    catch(RemoteException e){
    e.printStackTrace();
    }
    catch(NotBoundException e){
    e.printStackTrace();
    }
    }

    I am trying out the spring based RMI server configuration for the first time - But not sure if this is compatible with the typical RMI way of doing it ? Pls advice ...

  • #2
    Please use [ code][/code ] tags when posting code, that way it remains readable.

    Although it used RMI the internals work a little different, for the given beans etc. no stubs etc. are created. Spring has its own RMI stubs and those are exposed (your classcastexception tells you so). What actually is exposed is the RmiInvocationHandler which takes a RemoteInvocation which contains the specifics about the method to invoke. (Normally this is hidden by the RmiProxyFactoryBean).

    This setup saves you from creating all the stubs and rmi nasty ness you normally would need to do.

    Comment


    • #3
      Thanks a lot for a quick response. Yes the ClassCastException makes it clear too. Thanks for the confirmation. Going down this path is not going to help for our situation looks like.

      Comment

      Working...
      X