Spring Framework
  1. Spring Framework
  2. SPR-6277

RmiServiceExporter fails to export a UnicastRemoteObject

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.5.6
    • Fix Version/s: Waiting for Triage
    • Component/s: Remoting
    • Labels:
      None

      Description

      When setting a org.springframework.remoting.rmi.RmiServiceExporter with a bean that extends java.rmi.server.UnicastRemoteObject, the invocation fails (with an exception saying that the object is already exported via RMI).

      The problem comes from the UnicastRemoteObject constructor that automatically exports the bean, by default on port 0 (and the nature of UnicastRemoteObject forbids an instance to be exported more than once).

      There are two possible workarounds for that in the forum reference, but they both boil down to a simple thing: calling the UnicastRemoteObject.unexportObject(Remote, boolean) on the bean before attempting to export it with the parameters from Spring.

      For a true fix, I would put the additional lines in the RmiServiceExporter.prepare() method.

      I don't believe it would be useful to add a configuration parameter for that.

      Here is a basic testcase that should trigger the bug on Spring 2.5.6:

      The java class:

      package testcase;

      import java.rmi.RemoteException;
      import java.rmi.server.UnicastRemoteObject;

      public class BasicUnicastRemoteObject extends UnicastRemoteObject
      {
      protected BasicUnicastRemoteObject() throws RemoteException

      { super(); }

      }

      Beans configuration:

      <bean id="basic-unicast" class="testcase.BasicUnicastRemoteObject"/>

      <bean id="basic-rmi-exporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
      <property name="serviceName" value="basicUnicast"/>
      <property name="service" ref="basic-unicast"/>
      <property name="registryPort" value="1099"/>
      </bean>

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jean Hominal
            Last updater:
            Chris Beams
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              4 years, 26 weeks, 2 days ago

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified