Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Classsloading Problem
Classsloading Problem [message #461063] Thu, 04 January 2007 11:31 Go to next message
Eclipse UserFriend
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.j ava: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
Re: Classsloading Problem [message #461081 is a reply to message #461063] Thu, 04 January 2007 16:51 Go to previous messageGo to next message
Eclipse UserFriend
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.j ava: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
Re: Classsloading Problem [message #461171 is a reply to message #461081] Fri, 05 January 2007 11:56 Go to previous message
Eclipse UserFriend
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@CharlieKelly.com> schrieb im Newsbeitrag
news:enjst3$fhs$1@utils.eclipse.org...
> 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.j ava: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
Previous Topic:Ho to make packages in my feature available to plug-in developers
Next Topic:Views Interaction
Goto Forum:
  


Current Time: Tue Apr 15 00:55:22 EDT 2025

Powered by FUDForum. Page generated in 0.02882 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top