Hi Christian,

Thanks for the quick reply.

> this points to a class incompatiblity. The servicereference works with the 
> name of the interface "com.seecago.interfaces.MyService" but for getService 
> to work
> both the client and the service bundle must be bound to the same package 
> com.seecago.interfaces. I suspect that they see different versions of this 
> package.


> Do you maybe have the interface embedded in one or both of these bundles?
That was my suspicion as well. I am not aware of any embedded interfaces, but I 
will double check.

> You can check this with "package:imports" and "headers" on the bundle ids.
Will do, thanks again.

Erwin

> 
> Christian
> 
> On 23.02.2017 14:01, Erwin Hogeweg wrote:
>> Hi,
>> 
>> I am upgrading a system from CXF-2.7.2 and DOSGi-1.4 to 3.1.1/1.7.0 but I 
>> have run into a wall.
>> 
>> Before I start digging in the CXF code, would anyone have an idea why 
>> bundleContext.getService() would return a null object for a registered DOSGi 
>> service?
>> 
>> This is the remote service description:
>> 
>>   <endpoint-description>
>>     <property name="objectClass">
>>       <array>
>>         <value>com.seecago.service.interfaces.MyService</value>
>>       </array>
>>     </property>
>>     <property 
>> name="endpoint.id">http://my_service_host:12345/MyService/</property> 
>> <http://my_service_host:12345/MyService/%3C/property%3E>
>>     <property name="service.imported.configs">org.apache.cxf.ws</property>
>>   </endpoint-description>
>> 
>> 
>> The service is registered:
>> 
>> osgi> services (objectClass=*MyService)
>> {com.seecago.interfaces.MyService}={endpoint.id=http://my_service_host:12345/MyService/
>>  <http://my_service_host:12345/MyService/>, service.imported=true, 
>> service.imported.configs=org.apache.cxf.ws, service.id=163, 
>> service.bundleid=30, service.scope=bundle}
>>   "Registered by bundle:" cxf-dosgi-ri-dsw-cxf_1.7.0 [30]
>>   "No bundles using service."
>> 
>> 
>> This is a modified activator to prove that the service is null.
>> 
>> @Activate
>> public void activate(ComponentContext context){
>>      BundleContext bc = context.getBundleContext();
>> 
>>      // Added to see what is going on. setMyService() is not called
>>      if (bc != null){
>>              ServiceReference<MyService> sr = 
>> bc.getServiceReference(MyService.class);
>>              if (sr != null){
>>                      // verified that sr has correct props here
>>                      MyService ms = bc.getService(sr);
>>                      if (ms == null){
>>                              // Always get here.
>>                              LOG.error("Ouch!");
>>                      }
>>              }
>>      }
>>      LOG.info <http://log.info/>("Activated.");
>> }
>> 
>> This is the error msgs Equinox spits out:
>> 
>> !MESSAGE [SCR] Could not get the service object relevant to the reference. 
>> One possible reason is a circularity problem. Another possible reason is 
>> that BundleContext.getService() returns null. <—— WHICH APPEARS TO BE TRUE
>>      Details:
>>      Problematic reference = Reference[name = myService, interface = 
>> com.seecago.service.interfaces.MyService, policy = static, cardinality = 
>> 1..1, target = null, bind = setMyService, unbind = unsetMyService]
>>      of service component = com.seecago.client.ui.configuration
>> ...
>> 
>> DOSGi- 1.7.0
>> CXF - 3.1.1
>> Equinox- 3.12
>> J8
>> 
>> 
>> Your suggestions are greatly appreciated.
>> 
>> 
>> Regards,
>> 
>> Erwin
> 
> 
> -- 
> Christian Schneider
> http://www.liquid-reality.de <http://www.liquid-reality.de/>
> 
> Open Source Architect
> http://www.talend.com <http://www.talend.com/>

Reply via email to