Announcement Announcement Module
No announcement yet.
SPring based RMI service + Plain old RMI Client Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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=" tions"/>
    <property name="registryPort" value="${rmi.remoteSvc.port}"/>

    <bean id="remoteJournalOperationService" class=" 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);
    // 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){
    catch(NotBoundException e){

    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.


    • #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.