Service with RMI Binding cannot be promoted
-------------------------------------------

                 Key: TUSCANY-3683
                 URL: https://issues.apache.org/jira/browse/TUSCANY-3683
             Project: Tuscany
          Issue Type: Bug
    Affects Versions: Java-SCA-1.6
         Environment: JDK 1.6.0_21, Windows XP
            Reporter: Sebastian Millies
            Priority: Minor


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.




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to