My guess is that you are trying to start a framework from inside a framework, and then the code outside is using a different view of the ComponentFactory interface from the code inside. Normally you would need to use a system packages extra property when launching the inner framework (to share the package from outside to inside), or use reflection to access the service instance.
Best Regards, Tim Sent from my iPhone > On 28 Nov 2018, at 13:11, Thomas Driessen via osgi-dev > <osgi-dev@mail.osgi.org> wrote: > > Hi, > > I'm trying to setup an OSGi framework instance (Felix) then to install two > bundles and finally getting a reference to a ComponentFactory inside the > framework via a ServiceListener. No Exceptions are thrown but my > ServiceListener ist not getting any events. > > You can have a look at the code here: > https://github.com/Sandared/jmh-benchmarks/blob/master/benchmarks/src/main/java/io/jatoms/jmh/OSGiBenchmark2.java > > Or If you want to execute it and play with it you can run it here: > https://gitpod.io/#https://github.com/Sandared/jmh-benchmarks/blob/master/benchmarks/src/main/java/io/jatoms/jmh/OSGiBenchmark2.java > > just type the following commands into the terminal: > cd benchmarks > mvn clean install > java -jar target/benchmarks.jar > > I also tried to acquire the service directly by starting the bundles, then > wait a second and then calling > bundleContext.getServiceReference(ComponentFactory.class). But when I tried > to turn this reference into a service via > > ComponentFactory<ITest> factory = bundleContext.getService(ref); > > I get a ClassCastException stating that Felix SCR's > ComponentFactoryImplementation cannot be cast to ComponentFactory... which > doesn't make much sense to me, as the ComponentFactoryImplementation > implements ComponentFactory. > > Am I doing something fundamentally wrong? > > Kind regards, > Thomas > > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev