Re: ClassCastException after retrieving an Entry

Mike Francis <[email protected]> Thu, 4 Jan 2007 21:36:40 -0000
Newsgroups gmane.comp.java.sun.javaspaces
Organization Paremus
Message-ID <01c301c73048$6beab170$0400a8c0@MikeFrancis>
Hi

Just a general note - if anyone is trying to use OSGi with Jini please do
take a look at the Newton Project at www.codecauldron.org - its open source
and it takes away all these classloader issues. Honestly its easy and it
just works.

You may also be interested in the following article on EclipseZone from
earlier this week: http://www.eclipsezone.com/eclipse/forums/t87966.html.

Blatant promotion over :-)

Regards
Mike

Mike Francis
www.paremus.com

-----Original Message-----
From: Dan Creswell [mailto:[email protected]]
Sent: 04 January 2007 18:45
To: [email protected]
Subject: Re: ClassCastException after retrieving an Entry

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:computegrid
@192.168.0.200/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

________________________________________________________________________
This email has been scanned by both Message Labs and Paremus internal
systems for viruses and inappropriate attachments.  Email suspected of
carrying a virus payload or inappropriate attachment will not be
delivered to you, and the sender will receive an appropriate warning notice.

Paremus Limited.
107-111 Fleet Street, London EC4A 2AB.  Phone number +44 20 7936 9098
________________________________________________________________________


________________________________________________________________________
The information transmitted is intended only for the person(s) or entity
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the
material from any computer.

Paremus Limited.
107-111 Fleet Street, London EC4A 2AB.  Phone number +44 20 7936 9098
________________________________________________________________________

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