Re: ClassCastException after retrieving an Entry
Christian Hager <[email protected]> Thu, 4 Jan 2007 18:22:23 +0100
| Newsgroups | gmane.comp.java.sun.javaspaces |
|---|---|
| Organization | Analytic Company GmbH |
| Message-ID | <006e01c73024$e5ea6c50$0b00a8c0@acwschristian> |
Ok I did this
> Class[]cs = entry.getClass().getClasses();
> for( Class c : cs ) {
> System.out.println(c.getName()+": loader="+c.getClassLoader() );
> }
But getClasses() returns an empty array. Maybe it helps if I explain a
little more about TaskEntry. TaskEntry is supposed to be a generic task
which all my special tasks extend. My worker is supposed to be generic so it
uses TaskEntry as a template to find any task. It excutes the taken task and
puts the result back in the JavaSpace.
----- Original Message -----
From: "Gregg Wonderly" <[email protected]>
To: "Christian Hager" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, January 04, 2007 5:31 PM
Subject: Re: ClassCastException after retrieving an Entry
> Christian Hager wrote:
>> 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
>>
>> 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
>
> Okay, so this doesn't tell us the answer yet. The next thing that you
> need to do is
>
> Class[]cs = entry.getClass().getClasses();
> for( Class c : cs ) {
> System.out.println(c.getName()+": loader="+c.getClassLoader() );
> }
>
> to see what each class in the entry is loaded by. In particular, the
> loader for TaskEntry needs to be the same class loader as "My TaskEntry
> Loader" shows.
>
> 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