felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Gravell <elstensoftw...@googlemail.com>
Subject Re: Help me understand ClassCastException after update
Date Sat, 30 Jun 2012 16:57:19 GMT
Yeah, I think it must be something like that.

As posted above, I do a refresh, but after the update. The update is
performed by OBR to deploy() the latest bundle, which sucks in the
dependencies and performs the Activator restart which then fails with the
original CCE. The bundle appears not to be a STARTED state after the
Activator failure, and so when I try to do the refresh:

context.getBundle(0).adapt(FrameworkWiring.class).resolveBundles(null);

That fails with:

    java.lang.IllegalStateException: Invalid BundleContext.
    at
org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:514)
    at
org.apache.felix.framework.BundleContextImpl.getBundle(BundleContextImpl.java:173)

But I might be doing this wrong. This is called from a bundle that is
itself updated, so maybe that BundleContext is now stale? Or maybe it's
just the fact that the newly updated bundle is not STARTED because of the
CCE.

Dan

On Sat, Jun 30, 2012 at 5:46 PM, Richard S. Hall <heavy@ungoverned.org>wrote:

> Updating the service doesn't completely get rid of its old exports, you
> need to refresh it to do that. Most likely if you updated the client first,
> then it gets wired to the old export and stays that way after you update
> the server. Regardless, if you want to make sure you don't have any old
> "stale" versions causing you confusion, you have to do a "refresh" after a
> series of updates and uninstalls.
>
> -> richard
>
>
> On 6/30/12 12:09, Dan Gravell wrote:
>
>> My OSGi adventure continues...
>>
>> I have a bundle "Client" and bundle "Server". In Client's activator it
>> invokes code in Server, returning an object from Server, let's call it
>> server.A. A is defined in Server. Client then registers A as a service:
>>
>> context.registerService(A.**class, (A) serverClass.getA(), new
>> Hashtable());
>>
>> This works when it is first run.
>>
>> If I then update Client and Server bundles, the Client Activator gets run
>> again. This time I get a ClassCastException saying "server.A cannot be
>> cast
>> to server.A".
>>
>> So I guess the classloaders are different for the A that is returned by
>> Server to the one Client sees. Given both bundles were updated at the same
>> time, why is this?
>>
>> I make use of package versioning, if this is important. A's package,
>> server, was not updated, and its version was not incremented. Was the code
>> in Client using the old version of server.A?
>>
>> I guess registering A as a service in Client, rather than Server, is
>> opposed to most sample code I see but is it the cause of the problem? If
>> classloaders work on a per package level then it won't help will it?
>>
>> Thanks,
>> Dan
>>
>>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<users-unsubscribe@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message