Hi Tim, hi Tom,
thanks for your answers, which got me on the right path.
I solved the issue via:
config.put("org.osgi.framework.bootdelegation",
"org.osgi.service.component");
config.put("org.osgi.framework.bundle.parent", "framework");
org.osgi.framework.system.packages.extra=org.osgi.service.component had
no effect.
I know this is a bad hack, but its no code I really use. It's just to
get some benchmarks working, which are just out of personal interest ;)
Thank you so much. This issue kept me busy for a whole day.
Kind regards,
Thomas
------ Originalnachricht ------
Von: "Thomas Watson" <tjwat...@us.ibm.com>
An: thomas.driessen...@gmail.com; osgi-dev@mail.osgi.org
Gesendet: 28.11.2018 14:43:33
Betreff: Re: [osgi-dev] No service events for an embedded OSGi
Framework?
This is because your bootstrap code is loading a different copy of the
org.osgi.service.component package than that of the felix SCR
implementation bundle inside the framework. I'm sure if your listener
implemented AllServiceListener then you would see the events for the
service, but you would still not be able to cast anything to the
org.osgi.service.component package since there are two versions of this
package floating around.
Code loaded outside of the framework (and booting the framework) will
not be able to use the same packages as the bundles installed in the
framework (except for the packages provided by the framework itself or
the JVM). You may try setting the framework property to have the
org.osgi.service.component exported by the system.bundle in an attempt
to have the bundles in the framework use the same copy of the package
as the boot strap code:
org.osgi.framework.system.packages.extra=org.osgi.service.component
But to be honest this is an approach I would avoid and instead I would
try to install a third bundle that does the testing you need inside the
framework.
Tom
----- Original message -----
From: Thomas Driessen via osgi-dev <osgi-dev@mail.osgi.org>
Sent by: osgi-dev-boun...@mail.osgi.org
To: "OSGi Developer Mail List" <osgi-dev@mail.osgi.org>
Cc:
Subject: [osgi-dev] No service events for an embedded OSGi Framework?
Date: Wed, Nov 28, 2018 7:11 AM
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