0
votes

I have 2 osgi bundles (say A and B) running in Jboss Fuse. I am using Felix. 'A' bundle exposes a service which 'B' bundle uses. When I deploy both these bundles there is no problem. When I execute osgi:ls -u, I see that bundle 'B' is using service exposed by bundle 'A'

After I restart these 2 bundles together Bundle 'B' cannot find service exposed by Bundle 'A'. At this stage if I execute command osgi:ls, I see OSGI service exposed by bundle 'A'. When I execute osgi:ls -u, I don't see that bundle 'B' is using service exposed by bundle 'A'

I got 2 workaround for this problem

  1. At this stage if I restart only bundle 'B', then bundle 'B' finds OSGI service exposed by Bundle 'A'. Restarting bundle is not obvious official solution :)
  2. In bundle 'B', while importing osgi service, if add cardinality as 0:1 then I don't find any issue. But I cant do this as service exposed by bundle 'A' is mandatory for some functionality in bundle 'B'

Can anyone tell me why I am observing this behavior and how I can resolve it ? ?

1
Do you use spring:osgi to consume and expose the services ? - CourseTriangle

1 Answers

0
votes

Noted that this could happen when bundle B creates its app ctx outside the normal spring extender process. For instance, bundle B creates an app ctx based on an external event and the app ctx imports the osgi service exported from the bundle A. If you are using spring-dm to export/import osgi services, use ServiceTracker via BundleActivator instead.