ClassLoader Problem (ClassCastException)? [message #461543] |
Thu, 11 January 2007 12:45  |
Eclipse User |
|
|
|
Hi,
I'm having some difficulties with osgi classloading and I'm hoping
someone here can help me.
I have one class ResultEntry and a class FactorialResult which extends
ResultEntry. Now in one of my bundles I get an resultEntry object which
really is a FactorialTask from another bundle an then I want to
FactorialTask using the following code
FactorialResult fact = (FactorialResult) resultEntry;
Now when I try to do so I get a the following exception.
java.lang.ClassCastException:
org.ac.computegrid.jobs.fibfact.FactorialResult
at
org.ac.computegrid.jobs.fibfact.FibFactJob.addResultEntry(Fi bFactJob.java
:79)
at
org.ac.computegrid.master.GenericMaster$2.run(GenericMaster. java:167)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Following this I have also displayed the ClassLoaderTrees as I get them
with this code
ClassLoaderUtil.displayContextClassLoaderTree ();
ClassLoaderUtil.displayClassLoaderTree(FactorialResult.class
..getClassLoader ());
ClassLoaderUtil.displayClassLoaderTree (resultEntry.getClass
().getClassLoader ());
ClassLoaderUtil.displayClassLoaderTree (ResultEntry.class.getClassLoader
());
and here the output
ClassLoader Tree has 3 levels
cl0 -- Boot ClassLoader
|
cl1 -- ClassLoader
org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@1b06041: is
unknown ClassLoader type
|
cl2 -- ClassLoader
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@19422d2: is
unknown ClassLoader type
ClassLoader Tree has 3 levels
cl0 -- Boot ClassLoader
|
cl1 -- ClassLoader
org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@1b06041: is
unknown ClassLoader type
|
cl2 -- ClassLoader
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@467991: is
unknown ClassLoader type
ClassLoader Tree has 4 levels
cl0 -- Boot ClassLoader
|
cl1 -- ClassLoader
org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@1b06041: is
unknown ClassLoader type
|
cl2 -- ClassLoader
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@19422d2: is
unknown ClassLoader type
|
cl3 -- ClassLoader
sun.rmi.server.LoaderHandler$Loader@1174ec5["ahttp://computegrid:computeg
rid@192.168.0.200/codebase/computegrid_jobs.jar"]:
ahttp://computegrid:computegrid@192.168.0.200/codebase/compu tegrid_jobs.j
ar
ClassLoader Tree has 3 levels
cl0 -- Boot ClassLoader
|
cl1 -- ClassLoader
org.eclipse.osgi.baseadaptor.BaseAdaptor$ParentClassLoader@1b06041: is
unknown ClassLoader type
|
cl2 -- ClassLoader
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@19422d2: is
unknown ClassLoader type
Can anyone tell me how to solve this? Ah if it helps the ResultEntry
object comes from a JavaSpace
Thanks for any help
Christian Hager
|
|
|
|
|
|
|
|
|
Re: ClassLoader Problem (ClassCastException)? [message #461616 is a reply to message #461614] |
Sat, 13 January 2007 14:07   |
Eclipse User |
|
|
|
In article <eob5n1$49b$1@utils.eclipse.org>,
Paul Webster <pwebster@ca.ibm.com> wrote:
> Christian Hager wrote:
> > Ok let me try to explain more in detail. First we have Plugin A which
> > contains ResultEntry, second Plugin B which contains the
> > FactorialResult. Now I've Plugin C which requires A and takes the
> > ResultEntry from the JavaSpace and hands it over to Plugin B. Plugin B
> > requires Plugin A and itsself contains FactorialResult as told above. So
> > if I get your description right I should be able to cast, right?
>
> Who is doing the cast? Plugin B, after Plugin C hands it the resultEntry?
>
> If plugin A creates the object, it will only be a ResultEntry, right?
> That cannot be cast to a FactorialResult, since it isn't one.
>
> If I've misinterpreted your description, please post again :-)
>
> Later,
> PW
Plugin B is doing the cast. The object really is a FactorialResult which
I can see from the eclipse debugger. It is created remotely by my worker
application and stored in the javaspace. Plugin C takes it from the
JavaSpace with the code from my post before.
|
|
|
|
|
Re: ClassLoader Problem (ClassCastException)? [message #461643 is a reply to message #461622] |
Mon, 15 January 2007 05:41  |
Eclipse User |
|
|
|
Thanks you're great. Setting the classloader of plugin B before taking from
the space actually did the job.
"Paul Webster" <pwebster@ca.ibm.com> schrieb im Newsbeitrag
news:eobs2c$i89$2@utils.eclipse.org...
> Paul Webster wrote:
>> Maybe you need to pass it plugin C's classloader?
>
> After I posted this, I think this might not work either (although it's
> worth a try). I think the OSGi classloaders don't use parent classloading
> ... or do they? :-)
>
> Later,
> PW
|
|
|
Powered by
FUDForum. Page generated in 0.03193 seconds