Re: ClassCastException after retrieving an Entry

Dan Creswell <[email protected]> Thu, 4 Jan 2007 18:44:48 +0000
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Christian Hager wrote:
> Hello,
>
>
> As for the PREFFERED.LIST file I don't really know. I didn't create on so I
> asume there is none. I'm using the Standard Installation of Jini 2.1 and
> Blitz 1.29 on Win XP.
>
> I tried the thing with  the classloader and it gives me
>
> My Entry Loader:
> sun.rmi.server.LoaderHandler$Loader@1930ebb["ahttp://computegrid:[email protected]/codebase/codebase.jar"]
>
> My TaskEntry Loader:
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1079781
>

Uh oh, what's this OSGI classloader doing in here????

> for the following code
>
> Entry entry = javaSpace.take (taskTmpl, txn, 30000);
> System.out.println("My Entry Loader: "+ entry.getClass().getClassLoader());
> System.out.println("My TaskEntry Loader: "+
> TaskEntry.class.getClassLoader());
> TaskEntry task = (TaskEntry) javaSpace.take (taskTmpl, txn, 30000);
>
> the Exception then occurs in the 4th line of the code and is as follows
>
> java.lang.ClassCastException: org.ac.computegrid.TaskEntry
> at org.ac.computegrid.worker.GenericWorker.loop(GenericWorker.java:123)
> at org.ac.mvc.ExtThread.run(ExtThread.java:399)
> at java.lang.Thread.run(Unknown Source)
>
> The TaskEntry class is in the codebase and as seen above and seems to be
> taken from there.
>
> Since it seems to be a classloading problem it might also be important that
> my worker is an eclipse rcp plugin.
>

And there's the answer - yes that's very important because eclipse has
it's way of doing classloading and Blitz and other Jini bits have
another way of structuring it all.

I think it's time to insert some usages of:

com.sun.jini.start.ClassLoaderUtil.displayClassLoaderTree()

For each of these classloaders...

e.g.

ClassLoaderUtil.displayClassLoaderTree(TaskEntry.class.getClassLoader());

> Thanks again for any help
>
> Christian Hager
>
> ===========================================================================
> 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
>

===========================================================================
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