[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Classsloading Problem

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