Uploaded image for project: 'Tuscany'
  1. Tuscany
  2. TUSCANY-3683

Service with RMI Binding cannot be promoted

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Java-SCA-1.6
    • Java-SCA-1.6.1
    • None
    • None
    • JDK 1.6.0_21, Windows XP
    • 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.

      Attachments

        1. DefaultRMIHost.patch
          0.7 kB
          Sebastian Millies

        Activity

          People

            scnash Simon Nash
            s.millies@ids-scheer.de Sebastian Millies
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: