Affects Version/s: Java-SCA-1.6
Fix Version/s: Java-SCA-1.6.1
Environment:JDK 1.6.0_21, Windows XP
Patch Info:Patch Available
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/">
<ts:binding.rmi host="localhost" port="1099" serviceName="LogAdapterServiceRMI"/> <!-- *** -->
<service name="SLF4JLogAdapterService" promote="SLF4JAdapterComponent/LogAdapterService"/> <!-- *** -->
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"/>
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.
|Status||Open [ 1 ]||Resolved [ 5 ]|
|Assignee||Simon Nash [ scnash ]|
|Fix Version/s||Java-SCA-1.6.1 [ 12315362 ]|
|Resolution||Fixed [ 1 ]|
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|1h||1||Simon Nash||22/Sep/10 19:27|