You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Pablo Gomez <pa...@faw.jku.at> on 2016/02/01 10:53:46 UTC

remote services connection dosgi

Hello all,


        I've discovered recently remote services and I'm amazed about 
how easy to use and powerfull seems to be. However, I'm currently facing 
a small issue which I don't know what the reason could be.
I'm testing the greeter example in two containers, one of them provides 
the service whereas the other consumes it.
One container runs on a VirtualBox  linux machine  while the other runs 
on a windows host. I've tested with the following settings, NAT, 
host-only and Bridged network.
  Bridged network  works as expected so as to physical machines 
connected to the same LAN do. However, with the virtual machine 
configured as host-only setup, I'm not able to access to it with the 
OSGi consumer, the activator when calling super.addingService(reference) 
return null. Surprisingly,I can successfully access to the service with 
the browser though. I do not have a deep knowledge on networks so I 
can't see what I am missing here. Additionally, I had faced the same 
issue -being able to access with the browser but not with OSGi by 
running the two instances, consumer and provider in the same machine and 
OS. In this scenario, again I can consume the service with the browser 
but I get null in the osgi consumer activator so I can't manage to 
consume successfully the service. Do you guys have a hint that helps me 
to understand what's going here? I'd really like to understand why this 
happens.

Below the  Greeter activator that I'm using in the consumer:
public class Activator implements BundleActivator {

     private ServiceTracker tracker;


     public void start(final BundleContext bc) {
         tracker = new ServiceTracker(bc, 
GreeterService.class.getName(), null) {
             @Override
             public Object addingService(ServiceReference reference) {

                 Object service = super.addingService(reference);

                 if (service instanceof GreeterService) {
                     useService((GreeterService) service);
                 }
                 return service;
             }
         };
         tracker.open();
     }


Thank you!

regards
Pablo



-- 
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission.

Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.

Re: remote services connection dosgi

Posted by Pablo Gomez <pa...@faw.jku.at>.
Hi Christian,
        thank you for your reply and nice tutorials. I'm currently going 
through and learning Karaf. So far we were also working on a project 
with an ad-hoc container to which we should care to provide the things 
we need such as blueprint,jpa,wicket,jetty,etc... besides doing tweaks 
in the bundle start level so all in all I found that always painful. 
Karaf looks definitely promising

I'm now testing under Karaf 4.0.4. Are the endpoints still supported? 
I'm working with a very simple bundle with the following endpoint 
definition:

<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
   <endpoint-description>
     <property name="objectClass">
       <array>
         <value>org.test.sync.api.ISyncProvider</value>
       </array>
     </property>
     <property name="endpoint.id" value="http://localhost:9090/sync/"/>
     <property name="service.imported.configs" value="org.apache.cxf.ws"/>
   </endpoint-description>
</endpoint-descriptions>

Two containers with the following setup:

feature:repo-add cxf-dosgi 1.7.0
feature:install cxf-dosgi-discovery-distributed
feature:repo-add mvn:org.test/org.test.features/0.0.1-SNAPSHOT/xml
feature:install org.test.sync

The provider deploys successfully and I can access with the browser, but 
the client throws the following exception:
I've seen sometimes before that exception in the ad-hoc container but 
not always so I couldn't manage to figure it out what was the reason. 
But now in Karaf it is always thrown so it must be either that I'm 
missing some feature to be installed or that definition should be done 
in a  different way. Below the exception:

2016-02-03 14:45:15,273 | WARN  | lixDispatchQueue | 
ServiceDecoratorImpl             | 54 - cxf-dosgi-ri-dsw-cxf - 1.7.0 | 
Problem parsing: 
bundle://125.0:0/OSGI-INF/remote-service/remote-services.xml
javax.xml.bind.UnmarshalException
  - with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1.a: Cannot find the declaration 
of element 'endpoint-descriptions'.]
         at 
javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:350)[:2.5.0]
         at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:578)[84:org.apache.servicemix.bundles.jaxb-impl:2.2.11.1]
         at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:264)[84:org.apache.servicemix.bundles.jaxb-impl:2.2.11.1]
         at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:236)[84:org.apache.servicemix.bundles.jaxb-impl:2.2.11.1]
         at 
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:291)[84:org.apache.servicemix.bundles.jaxb-impl:2.2.11.1]
         at 
org.apache.cxf.dosgi.dsw.decorator.DecorationParser.getDecorations(DecorationParser.java:71)[54:cxf-dosgi-ri-dsw-cxf:1.7.0]
         at 
org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorImpl.getDecorationElements(ServiceDecoratorImpl.java:78)[54:cxf-dosgi-ri-dsw-cxf:1.7.0]
         at 
org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorImpl.addDecorations(ServiceDecoratorImpl.java:52)[54:cxf-dosgi-ri-dsw-cxf:1.7.0]
         at 
org.apache.cxf.dosgi.dsw.decorator.ServiceDecoratorBundleListener.bundleChanged(ServiceDecoratorBundleListener.java:40)[54:cxf-dosgi-ri-dsw-cxf:1.7.0]
         at 
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:916)[org.apache.felix.framework-5.4.0.jar:]
         at 
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:835)[org.apache.felix.framework-5.4.0.jar:]
         at 
org.apache.felix.framework.util.EventDispatcher.run(EventDispatcher.java:1148)[org.apache.felix.framework-5.4.0.jar:]
         at 
org.apache.felix.framework.util.EventDispatcher.access$000(EventDispatcher.java:55)[org.apache.felix.framework-5.4.0.jar:]
         at 
org.apache.felix.framework.util.EventDispatcher$1.run(EventDispatcher.java:103)[org.apache.felix.framework-5.4.0.jar:]

Best
Pablo

On 02/02/2016 8:56 AM, Christian Schneider wrote:
> The Greeter example on the website is quite old.
>
> Can you also try with the karaf based example on my website?
> http://www.liquid-reality.de/x/D4C
>
> It is much easier to install and uses the newest cxf DOSGi 1.7.0.
>
> Christian
>
> On 01.02.2016 10:53, Pablo Gomez wrote:
>> Hello all,
>>
>>
>>        I've discovered recently remote services and I'm amazed about 
>> how easy to use and powerfull seems to be. However, I'm currently 
>> facing a small issue which I don't know what the reason could be.
>> I'm testing the greeter example in two containers, one of them 
>> provides the service whereas the other consumes it.
>> One container runs on a VirtualBox  linux machine  while the other 
>> runs on a windows host. I've tested with the following settings, NAT, 
>> host-only and Bridged network.
>>  Bridged network  works as expected so as to physical machines 
>> connected to the same LAN do. However, with the virtual machine 
>> configured as host-only setup, I'm not able to access to it with the 
>> OSGi consumer, the activator when calling 
>> super.addingService(reference) return null. Surprisingly,I can 
>> successfully access to the service with the browser though. I do not 
>> have a deep knowledge on networks so I can't see what I am missing 
>> here. Additionally, I had faced the same issue -being able to access 
>> with the browser but not with OSGi by running the two instances, 
>> consumer and provider in the same machine and OS. In this scenario, 
>> again I can consume the service with the browser but I get null in 
>> the osgi consumer activator so I can't manage to consume successfully 
>> the service. Do you guys have a hint that helps me to understand 
>> what's going here? I'd really like to understand why this happens.
>>
>> Below the  Greeter activator that I'm using in the consumer:
>> public class Activator implements BundleActivator {
>>
>>     private ServiceTracker tracker;
>>
>>
>>     public void start(final BundleContext bc) {
>>         tracker = new ServiceTracker(bc, 
>> GreeterService.class.getName(), null) {
>>             @Override
>>             public Object addingService(ServiceReference reference) {
>>
>>                 Object service = super.addingService(reference);
>>
>>                 if (service instanceof GreeterService) {
>>                     useService((GreeterService) service);
>>                 }
>>                 return service;
>>             }
>>         };
>>         tracker.open();
>>     }
>>
>>
>> Thank you!
>>
>> regards
>> Pablo
>>
>>
>>

Re: remote services connection dosgi

Posted by Christian Schneider <ch...@die-schneider.net>.
The Greeter example on the website is quite old.

Can you also try with the karaf based example on my website?
http://www.liquid-reality.de/x/D4C

It is much easier to install and uses the newest cxf DOSGi 1.7.0.

Christian

On 01.02.2016 10:53, Pablo Gomez wrote:
> Hello all,
>
>
>        I've discovered recently remote services and I'm amazed about 
> how easy to use and powerfull seems to be. However, I'm currently 
> facing a small issue which I don't know what the reason could be.
> I'm testing the greeter example in two containers, one of them 
> provides the service whereas the other consumes it.
> One container runs on a VirtualBox  linux machine  while the other 
> runs on a windows host. I've tested with the following settings, NAT, 
> host-only and Bridged network.
>  Bridged network  works as expected so as to physical machines 
> connected to the same LAN do. However, with the virtual machine 
> configured as host-only setup, I'm not able to access to it with the 
> OSGi consumer, the activator when calling 
> super.addingService(reference) return null. Surprisingly,I can 
> successfully access to the service with the browser though. I do not 
> have a deep knowledge on networks so I can't see what I am missing 
> here. Additionally, I had faced the same issue -being able to access 
> with the browser but not with OSGi by running the two instances, 
> consumer and provider in the same machine and OS. In this scenario, 
> again I can consume the service with the browser but I get null in the 
> osgi consumer activator so I can't manage to consume successfully the 
> service. Do you guys have a hint that helps me to understand what's 
> going here? I'd really like to understand why this happens.
>
> Below the  Greeter activator that I'm using in the consumer:
> public class Activator implements BundleActivator {
>
>     private ServiceTracker tracker;
>
>
>     public void start(final BundleContext bc) {
>         tracker = new ServiceTracker(bc, 
> GreeterService.class.getName(), null) {
>             @Override
>             public Object addingService(ServiceReference reference) {
>
>                 Object service = super.addingService(reference);
>
>                 if (service instanceof GreeterService) {
>                     useService((GreeterService) service);
>                 }
>                 return service;
>             }
>         };
>         tracker.open();
>     }
>
>
> Thank you!
>
> regards
> Pablo
>
>
>


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com