Re: ClassCastException after retrieving an Entry

Gregg Wonderly <[email protected]> Fri, 5 Jan 2007 07:46:20 -0600
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Christian Hager wrote:
> Ok I've put the code in. It now looks like the following.
>
> Entry entry = javaSpace.take (taskTmpl, txn, 30000);
> ClassLoaderUtil.displayClassLoaderTree(entry.getClass ().getClassLoader());
> ClassLoaderUtil.displayClassLoaderTree(TaskEntry.class.getClassLoader());
> ...
>
> and that is what I get.

Okay, this is interesting, but not complete.  It shows that there is only the
boot classloader in common between these two objects class loader trees.  The
origin of TaskEntry is hidden from the remote code because it's not loaded from
a visible classloader.  I'd suggest that you might try

Thread.currentThread().setContextClassLoader( TaskEntry.getClassLoader() );

prior to the space.take() call to make that classloader visible.

I'm not familiar with what eclipse is doing under the covers, but it appears to
be isolating your code.  It might be that even the above will not work because
eclipse is using a different classloader resolution strategy than the J2SE
loaders which always look at the context loader first, and then the app
classloader tree.

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