Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [SOLVED] ClassNotFoundException(cross bundle class loading)
[SOLVED] ClassNotFoundException [message #778290] Thu, 12 January 2012 07:47 Go to next message
Carusyte Missing name is currently offline Carusyte Missing nameFriend
Messages: 27
Registered: July 2009
Junior Member
I tried several solutions but I kept getting the ClassNotFoundException. I'll try to elaborate the problem:
My rcp project (bundle A) calls a static method defined in another rcp project (bundle B), which helps deserialize an object from the preference service. The stack trace if briefly as follows:

java.lang.ClassNotFoundException: cn.bocsoft.naso.core.model.entry.Port
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:603)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1623)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1322)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at cn.bocsoft.rcp.util.PrefUtil.getObject(PrefUtil.java:47)
...
...

I've tried using Buddy Class Loading, defined 'Eclipse-BuddyPolicy: registered' in bundle 'cn.bocsoft.rcp.util'(i.e. Bundle B) manifest and 'Eclipse-RegisterBuddy: cn.bocsoft.rcp.ui' in bundle A's manifest, and defined 'cn.bocsoft.naso.core.model.entry' in the export-package, but the problem still exists.

Any help would be appreciated, thanks in advanced!

[Updated on: Thu, 12 January 2012 08:34]

Report message to a moderator

Re: ClassNotFoundException [message #778300 is a reply to message #778290] Thu, 12 January 2012 08:15 Go to previous messageGo to next message
Carusyte Missing name is currently offline Carusyte Missing nameFriend
Messages: 27
Registered: July 2009
Junior Member
Eclipse Version: Helios Service Release 2
Build id: 20110218-0911

Osgi Bundle Version:
org.eclipse.osgi_3.6.2.R36x_v20110210.jar

I think the buddy class loading must be supported in this version, right?
Re: ClassNotFoundException [message #778301 is a reply to message #778290] Thu, 12 January 2012 08:33 Go to previous message
Carusyte Missing name is currently offline Carusyte Missing nameFriend
Messages: 27
Registered: July 2009
Junior Member
It's a stupid mistake...I should've defined
Eclipse-RegisterBuddy: cn.bocsoft.rcp.util

instead of
Eclipse-RegisterBuddy: cn.bocsoft.rcp.ui

in bundle A's manifest.
Sorry for this, the buddy class loading now finally solved the problem. Since I can't delete the post, to make it a bit useful for those who want to know more about buddy class loading, check this: http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements
Previous Topic:Column grouping
Next Topic:Can't have a button labeled "Stop"?
Goto Forum:
  


Current Time: Fri Apr 26 13:15:56 GMT 2024

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

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

Back to the top