As Neil said, make sure the newly installed
bundle B is started. If you are already starting bundle B then I
think something else is occurring.
In OSGi uninstalls and updates are "lazy".
Bundle A got resolved and wired to packages from the previously installed
version of B (by using Import-Package/Require-Bundle etc.). You uninstalled
bundle B but the framework is not allowed to completely remove the classloader
of Bundle B from the framework because Bundle A is currently wired to and
using the packages from Bundle B. Bundle B's classloader cannot be
completely removed from the framework until a org.osgi.service.packageadmin.PackageAdmin.refreshPackages
is called. This will force Bundle A to stop using the old packages
from the uninstalled version of bundle B and will then allow Bundle A to
get resolved and wired to the newly installed version of Bundle B.
The service registry in OSGi filters
service events based on package sources. If the framework determines
that the publishing bundle is wired to a different version of a package
than the listening bundle then the service event is not delivered to that
ServiceListener. See org.osgi.framework.ServiceReference.isAssignableTo(Bundle,
String) for more information. In your case Bundle A is wired to old
versions of the packages from Bundle B and will not be able to see the
service registered by the new version of Bundle B.
After uninstalling Bundle B and installing
a new version run the "refresh" command from the console. This
runs the PackageAdmin.refreshPackages command. This should force
Bundle A to be wired to the new version of Bundle B.
<njbartlett@xxxxxxxxx> Sent by: equinox-dev-bounces@xxxxxxxxxxx
04/12/2007 07:46 AM
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
"Equinox development mailing list"
Re: [equinox-dev] ServiceListener ignored
after Service Replacement
You said that bundle B* is "installed".
Do you mean "started"? If B* is
only installed but not activated, then it cannot register a service, and
naturally your ServiceListener will not be notified.
If that's not the problem, then check that the service registered by B*
matches the filter under which A is listening. Depending on the filter
have used in the addServiceListener() call, you might not be matching B*'s
service, e.g. if the properties are a little different.
Also take a look at the output of the Equinox commands "ss" and
"services". This might show up something useful.
> maybe this is just a stupid simple question, and I just don't see
> solution, if that's the matter sorry for bothering you.
> But here the scenario:
> I have 2 bundles A and B, A is using a service exported and registered
> The Service object used in A is wrapped by a dynamic proxy for managing
> service object and some synchronization issues. This proxy registers
> Service listener, using the Context of Bundle A, to react on Service
> in B and there is the problem:
> If bundle B gets uninstalled everything works fine, the Listener gets
> on the UNREGISTERING Event, the service object in the proxy is freed,
> a new bundle B*, implementing and exporting the service exported by
> B, is installed, the Listener doesn't get called on the REGISTERED
> so the Proxy cannot do its work and react to the again available Service.
> What do I miss? Is there any special filtering done in the equinox
> Thomas Fischer
> equinox-dev mailing list
equinox-dev mailing list