Re: AW: Using a Java Space from an OSGi bundle
Gregg Wonderly <[email protected]> Thu, 13 Sep 2007 14:22:44 -0500
| Newsgroups | gmane.comp.java.sun.javaspaces |
|---|---|
| Message-ID | <[email protected]> |
Wellmann, Harald wrote:
> Thanks, this demo pretty much corresponds to my use case, but if I see it working in Newton, I still don't know what's going on there and how to make it work in my own environment.
>
> So what is the key to solving the problem:
>
> 1) Publishing all classes from exported packages from OSGi bundles as an RMI codebase?
> 2) Somehow tell the OSGi framework that the downloaded JavaSpace proxy shall be regarded
> as local code and use the same class loaders.
> 3) Or a combination of 1) and 2).
>
> I tried exporting my Entry classes on an HTTP server and set the java.rmi.server.codebase on my OSGI VM accordingly. This got my a little further, I could now take entries from the space, but then I got a ClassCastException "Cannot cast MyEntry to MyEntry", apparently because MyEntry from the code base is not the same as MyEntry from the OSGi class loader.
>
> I saw that Knopflerfish has a Jini Driver bundle which seems to do 1). Would that solve my problem?
looking at the stack trace, it appears that you need to do
ClassLoader ld = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread.setContextClassLoader(
getClass().getClassLoader() );
// Do work that starts in Activator.run() here
} finally {
Thread.currentThread.setContextClassLoader( ld );
}
to make sure that the Thread which is running the code in Activator.run() can
find a ClassLoader which can load the classes from the codebase of the object
which can from the Javaspace.
Gregg Wonderly
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS". For general help, send email to
[email protected] and include in the body of the message "help".
To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html