views:

2293

answers:

2

details: I'm trying to use Jalapeno framework to connect my RCP app with Cache' database. After connection established, I'm trying to get all data from table exactly like in Jalapeno manual:

if (objManager==null) return;
DBClass cortege = null;
try {
Iterator terms = objManager.openByQuery(DBClass.class, null, null);
System.out.println("terms ok");
while (terms.hasNext()){
 System.out.println("has next");
 cortege = (DBClass)terms.next();
}

this code compiling, running and trowing exception

java.lang.RuntimeException: myPluginId.views.DBClass
at com.intersys.objects.POJOIterator.next(POJOIterator.java:75)
   ...skip...
   Caused by: java.lang.ClassNotFoundException: myPlugin.views.DBClass
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:129)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.jalapeno.runtime.ObjectCopierToPojo.detach(ObjectCopierToPojo.java:76)
    at com.jalapeno.runtime.ObjectCopierToPojo.findPojo(ObjectCopierToPojo.java:472)
    at com.intersys.classes.CacheRootObject.detach(CacheRootObject.java:255)
    at com.intersys.classes.Persistent.detach(Persistent.java:567)
    at com.intersys.objects.POJOIterator.next(POJOIterator.java:59)

at terms.next(); I can't get it at all... instance of class DBClass was just created, but class cannot be loaded. then I've tried to place this code in simple java application (not eclipse rcp) and all went ok. so I think some Eclipse part blocking class loading.

also i've tried to load class before calling terms.next();

Bundle b = Platform.getBundle("myPluginId");
try {
b.loadClass("DBClass");
} catch (ClassNotFoundException e) {
System.out.println("no class");
e.printStackTrace();
}

and got same error. class can not be loaded. so, is it known problem? is there a solution? =============================================== after some research updating the question: How to make Jalapeno plugin to load class from My plugin?

A: 

I am not sure, but maybe you have to export the package in which the classes are lying.

Select in the MANIFEST "Runtime" and add all packages

Markus Lausberg
tried. still don't work.
Imaskar
+1  A: 

You might want to try buddy classloading. For more info on Eclipse classloading, Alex Blewitt has written an excellent overview of the classloading system in Eclipse here. Its a few years old, but for the most part it is still relevant.

The jist of buddy classloading is this:

  • a plugin declares that it needs help loading classes. It does this by declaring its "buddy plugin"

  • the buddy plugin declares its buddy policy

  • when the regular loading mechanism fails, Eclipse tries to use the buddy classloading policies you have specified.

So in your case, try putting:

Eclipse-BuddyPolicy: registered

in your Jalapeno plugin's manifest.mf file

and put:

Eclipse-RegisterBuddy: id.of.jalepeno.plugin

in the manifest.mf of your plugin

nstehr
thanks! It helped! Just one thing: is there a way to improve performance, to skip regular mechanism (I suppose it iterates all classes in Jalapeno plugin) and use buddy-loading first (only in expected places... I mean where I know buddy loading will occur)?
Imaskar
glad it helped! But for second question, I can't think of any ways of the top of my head on how to improve the performance.
nstehr
ok, thanks. let it be as is
Imaskar