Tuscany
  1. Tuscany
  2. TUSCANY-3683

Service with RMI Binding cannot be promoted

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Java-SCA-1.6
    • Fix Version/s: Java-SCA-1.6.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      JDK 1.6.0_21, Windows XP
    • Patch Info:
      Patch Available

      Description

      A service with an RMI binding cannot be promoted, because when the binding for the promoted service is processed, the Tuscany CompositeActivatorImpl attempts to start the RMIServiceBindingProvider a second time, which leads to the DefaultRMIHost wanting to bind the service under the same name in the RMI registry, which produces an AlreadyBoundException.

      Here's a snippet from the composite.xml:

      <?xml version="1.0" encoding="UTF-8" standalone="no"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:ts="http://tuscany.apache.org/xmlns/sca/1.0" name="logger_composite" targetNamespace="http://ps.softwareag.com/">
      <component name="SLF4JAdapterComponent">
      <implementation.java class="com.softwareag.ps.platform.logadapter.impl.SLF4JAdapterImpl"/>
      <service name="LogAdapterService">
      <interface.java interface="com.softwareag.ps.platform.logadapter.LogAdapterService"/>
      <binding.sca/>
      <ts:binding.rmi host="localhost" port="1099" serviceName="LogAdapterServiceRMI"/> <!-- *** -->
      </service>
      </component>
      <service name="SLF4JLogAdapterService" promote="SLF4JAdapterComponent/LogAdapterService"/> <!-- *** -->
      </composite>

      The error occurs when the composite with the promoted binding is activated in isolation, independent of whether it is used as a component implementation.

      The service name that is registered twice in the rmiregistry is the serviceName attribute of the binding.rmi element, in this case "LogAdapterServiceRMI". (Note that this rmiregistry name is not the same as the service name.)

      One way to work around the error would be to provide an explicit RMI binding for the promoted service using a new RMI-name, e. g.:

      <service name="SLF4JLogAdapterService" promote="SLF4JAdapterComponent/LogAdapterService">
      <ts:binding.rmi host="localhost" port="1099" serviceName="PromotedLogAdapterServiceRMI"/>
      </service>

      But this seems somewhat counterintuitive - if no binding is specified for a promoted service, the binding for the component service should simply be taken from the original service definition.

      I propose a patch in org.apache.tuscany.sca.host.rmi.DefaultRMIHost#registerService(String, int, Remote). This method currently uses
      registry.bind(serviceName, serviceObject), instead it should use registry.rebind(serviceName, serviceObject). This avoids the error.
      However, I do not know if there was a good reason for this method to use the bind-method in the first place.

      1. DefaultRMIHost.patch
        0.7 kB
        Sebastian Millies

        Activity

        Hide
        Sebastian Millies added a comment -

        Patch for DefaultRMIHost.java

        Show
        Sebastian Millies added a comment - Patch for DefaultRMIHost.java
        Hide
        Simon Nash added a comment -

        Thanks, Sebastian!

        Patch applied under r1000121 in the 1.6.1 branch and r1000125 in the 1.x trunk.

        Show
        Simon Nash added a comment - Thanks, Sebastian! Patch applied under r1000121 in the 1.6.1 branch and r1000125 in the 1.x trunk.

          People

          • Assignee:
            Simon Nash
            Reporter:
            Sebastian Millies
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development