We have a decent sized osgi application which consist of approximately 80 custom service bundles with an additional 20 to 30 3rd party bundle dependencies at runtime (we are running R7 flavor of osgi). When we started this project we would typically use field injection of our services with the @Reference annotation and had no issues at all, but now, we are seeing more and more that these injected dependencies are sometimes randomly coming up as null - one way we have found to fix the issue is to replace the field injection with method injection of the services.
What I have noticed is, that where the injected services are typically coming up null is in our component services, which are effectively just Java classes with the @Component annotation slapped on, but which do not implement a "ProviderType" or "ConsumerType" interface (our REST endpoints are like this). We are already currently setting these component's property of "immediate=true" but this doesn't seem to have any effect on the injected services randomly coming up null.
When we check the list of bundles - all the correct bundles appear to be Active and sometimes even the services appear to be fine (NO Unsatisfied References) which is totally mind boggling.
Anyone who may have some insight on why this would be occurring?
Some ongoing abnormalities / possible causes: Since the beginning of the project we have seen the following error with almost all of our REST endpoints but don't know exactly why the framework thinks its seeing duplicate classes and methods. Both
fully.qualified.class.path.CustomServiceRest#doStuff and fully.qualified.class.path.CustomeServiceRest#doStuff are equal candidates for handling the current request which can lead to unpredictable results Dec 13, 2018 2:41:45 PM org.apache.cxf.jaxrs.model.OperationResourceInfoComparator compare WARNING: Both fully.qualified.class.path.CustomServiceRest#doSomeOtherStuff and fully.qualified.class.path.CustomServiceRest#doSomeOtherStuff are equal candidates for handling the current request which can lead to unpredictable results
Recently we have added an osgi WebSocket service which required an addition of another Jetty dependency bundle and there has been some concern about having the two Jetty bundles playing nice in the runtime mix.