[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: Classsloading Problem
|
Hi,
If I do that it works but that doesn't solve the problem. Ok I will see if I
can explain a little more in detail.
My Worker Application is supposed to be generic so that it can handle any
kind of task extending TaskEntry. So I write special tasks extending
TaskEntry and have them put into the space by my master application. The
classes of those specialized task I put on my http codebase. When I start
the worker I tell it to use this codebase by
giving -Djava.rmi.server.codebase="ahttp://comp... as a VM parameter.
The worker should then search for TaskEntrys not caring what task they are
and excute them and return the result to the space.
So if I would be able to load TaskEntry also with this RMIclassloader with
my custom codebase it would do the trick. But I don't know how to get
TaskEntry loaded by this classloader.
Maybe anyone has also other ideas how to reach my goal.
Thanks again for any help.
"Charle Kelly" <Eclipse@xxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:enjst3$fhs$1@xxxxxxxxxxxxxxxxxxxx
> Hi Christian,
>
> try the following to set the ContextClassLoader
>
>
> Thread thread = null;
> ClassLoader classLoader = null;
> try
> {
> thread = Thread.currentThread();
> ////////////////////////////////////////////////////////////////
> Class clazz = Class.forName("org.ac.computegrid.TaskEntry"); classLoader =
> thread.getContextClassLoader();
> thread.setContextClassLoader(clazz.getClassLoader() );
> ////////////////////////////////////////////////////////////////
> // Your code goes here
> ////////////////////////////////////////////////////////////////
> TaskEntry task = (TaskEntry) javaSpace.take (taskTmpl, txn, 30000); }//
> try
> catch (Exception e)
> {
> // your Exception handling
> }// catch (Exception e) finally
> {
> thread.setContextClassLoader(classLoader);
> }// finally
>
>
>
>
>
> Christian Hager wrote:
>> Hello,
>>
>>
>> I'm trying to built an application using RCP and JavaSpaces. Currently
>> I'm experiencing some classloading problems and was hoping someone here
>> could maybe help me solve them.
>> So here is what the problem is. I have a worker which is an RCP
>> Application and which is supposed to take entries from a JavaSpace
>> process them and put the results back into the space.
>> The Problem is when I try to take an Entry from the Space and want to
>> cast it I using the following code
>>
>> TaskEntry task = (TaskEntry) javaSpace.take (taskTmpl, txn, 30000);
>>
>> I get the following exception
>>
>> 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)
>>
>> I think the JavaSpace uses an RMIClassloader and the bundle does not
>> which makes the classes different. But I have no idea what I can do about
>> that. I was hoping anyone here has any idea of what I can do to make it
>> work.
>>
>> Thanks in advance for any help.
>>
>> Christian Hager