|Re: [ecf-dev] OSGi RemoteServices Error|
On 9/13/2016 2:14 PM, Ramachandran K. Narayanan wrote:
I don't think this is the right way to resolve this. Based upon what you say above, my suspicion is that the changes you are making to the remote service interface are adding some dependencies that pull in the PrintStackUtil class along with others.
But before going further with this, I would suggest starting from a different example than the Getting Started with Remote Services API. This example was introduced quite a few years ago...before OSGi Remote Services specification actually existed. Now it's much easier to use the OSGi Remote Services approach (less code for both the remote service registration and the consumer). The Getting Started you point to above should still work, and we don't want to remove it, but I would recommend using OSGi Remote Services/Remote Service Admin because it's both simpler and standardized.
Here, for example, is a getting started with OSGi Remote Services
There are other tutorials as well here:
There are also some examples of registering and consuming a remote service using Declarative Services annotations, which also simplifies things even further. I haven't yet had a chance to complete a tutorial for this but you can look at example api, provider, and consumer bundles here
This makes me think that your changes are introducing runtime dependencies (perhaps in bundles that are pulled in for other classes you are referencing). Can you describe the changes you are making to the examples? If you don't want them to be public then you could correspond with me directly at slewis at composent.com.
Well, I do think that OSGi Remote Services is the way to go. The model for OSGi RS/RSA is straightforward: local OSGi services are *exported* (provider) so they can then be discovered and *imported* by some other process. This allows you to avoid calling all the ECF RS-specific code that's in the Getting Started page. All of the necessary calls to export the service are made automatically as part of the service registration.
One of the tricky issues with both local and remote services is dependencies. For example, if your service interface includes references to packages and/or classes contained in some other bundle, then all those dependencies have to be available on both the provider/host and the consumer. It's very easy to include an entire tree of unwanted dependencies simply by importing one package into the bundle that contains your service interface. That's kind of what I'm suspecting is going on with your attempt to modify the example, resulting in the ClassNotFoundExceptions occurring in the code that's responsible for creating the remote service proxy on the consumer.
If you can let us know what changes you are looking to make to the service interface then we can probably help further. But I would suggest looking a the OSGI Remote Service tutorials and examples given above as they are simpler, smaller, and standardized.
Hope this helps.