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

Reply via email to