[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [equinox-dev] Framework launching and class loaders

Thanks BJ,
 
I went for the 2nd solution, exporting the package through org.osgi.framework.system.packages.extra.
It seems to work just fine!
 
-Patrik
 
 

From: equinox-dev-bounces@xxxxxxxxxxx [mailto:equinox-dev-bounces@xxxxxxxxxxx] On Behalf Of BJ Hargrave
Sent: den 25 maj 2009 15:12
To: Equinox development mailing list
Subject: Re: [equinox-dev] Framework launching and class loaders

The org.osgi.service.cm package has 2 "version" in your example. One loaded from a bundle and used by the ConfigurationAdmin service implementation and the other on the application classpath. You need to either use reflection to use the service (then you don't need the version on the classpath) or you need to configure the framework to export the version on the package on the application classpath from the system bundle (org.osgi.framework.systempackages.extra) so that the ConfigurationAdmin bundle uses that version of the package.
--

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the
OSGi Alliance
hargrave@xxxxxxxxxx

office: +1 386 848 1781
mobile: +1 386 848 3788




From: Jansson Patrik <patrik.jansson@xxxxxxxxxxxxx>
To: "equinox-dev@xxxxxxxxxxx" <equinox-dev@xxxxxxxxxxx>
Date: 2009/05/25 08:57
Subject: [equinox-dev] Framework launching and class loaders
Sent by: equinox-dev-bounces@xxxxxxxxxxx





I'm using the framework launching API to start an OSGi framework (which in this case is Equinox 3.5M6).
I need to pass some configuration from the launcher application to one of the bundles running so I thought
of using the ConfigurationAdmin service for this.
 
The launcher gets hold of a BundleContext (from the framework handle) and gets a reference to the
service; ServiceReference reference = context.getServiceReference(...)
 
But I get into trouble on the next step
ConfigurationAdmin cAdmin = (ConfigurationAdmin) context.getService(reference);
This throws a ClassCastException. The actual object returned uses equinox's class loader while the class I'm
trying to cast to, ConfigurationAdmin, is loaded through the launcher's standard class loader
(sun.misc.Launcher$AppClassLoader in this case).
 
How can I go around this? Shouldn't I be playing with OSGi services outside the framework like this? In
that case how should I pass configuration from the launcher to the bundle?
 
Thanks,
-Patrik Jansson
 _______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev