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:53:36 GMT
I think you might be right. Could this be a package versioning problem? A
is in a package that was *not* updated (although its holding bundle was),
and Client's version requirement for Import-Package for A's package had not

When I do a full VM restart it works fine, the versions are all updated.

Currently I update using OBR:


If it *is* a packaging problem and I need to increment the version of A's
package and the version requirements on all Import-Package declarations for
A's package... I'm beginning to wonder how on earth one can keep on top of
this. Granted: this is a legacy app converted to OSGi, so it is not
modularised perfectly. But it feels like it will be an enormous pain to
keep on top of package versioning. Hopefully bndtools can help with this...

To make it more confusing: A extends SuperA which is in a separate bundle
again. This separate bundle was also not updated. Furthermore, another
bundle again uses A, as I mentioned to Neil.


On Sat, Jun 30, 2012 at 5:30 PM, Christian Schneider <
chris@die-schneider.net> wrote:

> The service should not be involved in the problem. I think the client is
> still using the old class that was created by the classloader of the old
> server bundle. As it comes from a different classloader it is of course
> incompatible.
> Have you tried uninstalling client and server and then installing the new
> bundles. Then it should work.  How exactly do you do the update at the
> moment?
> Christian
> Am 30.06.2012 18:09, schrieb Dan Gravell:
>  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
> --
>  Christian Schneider
> http://www.liquid-reality.de
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<users-unsubscribe@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org

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