Classloader problem when deserializing [message #707526] |
Mon, 01 August 2011 15:18  |
Eclipse User |
|
|
|
Hi there.
I'm relatively new to OSGi and have been facing a problem, which I assume has to do with the classloaders. Here's my situation:
My goal is to serialize and deserialize a message(object), where the code for deserialization is on a different bundle than the one containing the class being serialized.
I have two bundles B1 and B2. The class to be (de)serialized is in B2.
A class (say C1) in B1 has the code for deserialization:
C1.received(byte[] buf, int offset, int length)
This class is extended in B2, to derive another class C2.
In B2, I have a object of type C2 for receiving serialized buffer, and I called
c2.received(buf, offset, length)
I get a ClassNotFound error inside that method while trying to deserialize, eventhough this method call is being made in B2.
When I moved the code for deserialization from the abstract class C1 to C2, it worked fine. Hence, I've come to the conclusion that when calling methods from superclasses that are on a different bundle, a "context switch" or something like that occurs (I'm not sure about the term used)
However, I need the deserialization code to be in the superclass C1 in bundle B1, to avoid duplicating it into all subclasses. How can I get this to work?
I tried using Eclipse-BuddyPolicy: dependent in B1's manifest, but that didn't do it either. Or do I need to start some bundle to get BuddyPolicy to work? Currently I'm only using the org.eclipse.osgi jar and my two jar files B1 and B2.
Any suggestions please
|
|
|
|
|
Re: Classloader problem when deserializing [message #708412 is a reply to message #708393] |
Tue, 02 August 2011 15:42  |
Eclipse User |
|
|
|
However... after using the Apache Commons IO bundle, i just found out that my bundles now run fine with KnopflerFish, but not with eclipse osgi.
With the eclipse OSGI, I get the following error:
java.lang.NoClassDefFoundError: org/apache/commons/io/input/ClassLoaderObjectInputStream
But the required bundles are all loaded, and the manifest has the necessary imports.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.7.0.v20110613
1 ACTIVE teletutor.core_1.0.0
3 ACTIVE TeleConsumer_1.0.0
4 ACTIVE com.springsource.org.apache.commons.io_1.4.0
I don't understand why it's working on one framework and not on the other...
|
|
|
Powered by
FUDForum. Page generated in 0.27069 seconds