The Source for Java Technology Collaboration
User: Password:



Sahoo's Blog

May 2008 Archives


Updated instructions to use OpenJPA in GlassFish

Posted by ss141213 on May 12, 2008 at 11:23 AM | Permalink | Comments (0)

Layout of OpenJPA installation has changed since I last blogged about using OpenJPA in GlassFish. Let's say one installs OpenJPA in a directory called ${OPENJPA_HOME}. Earlier (I am talking about the days when OpenJPA was still in Apache incubator), all the jars would live under ${OPENJPA_HOME}/lib directory. Now, things have changed. The primary artifact, openjpa-${version}.jar, which contains classes built out of OpenJPA codebase lives under ${OPENJPA_HOME}; where as all the other library jars live under ${OPENJPA_HOME}/lib. So, all you need to do is to copy the appropriate jars like this:

 cp ${OPENJPA_HOME}/openjpa*.jar ${OPENJPA_HOME}/lib/*.jar ${GLASSFISH_HOME}/domains/domain1/lib 

and restart GlassFish. For further information, please refer to my earlier blog. I have updated that blog as well.

For issues, please don't hesitate to contact us at users (at) glassfish.dev.java.net



Bug in Bundle.getResource() in Knopflerfish?

Posted by ss141213 on May 01, 2008 at 12:38 AM | Permalink | Comments (4)

I was running a simple test on multiple OSGi platforms. I am seeing some difference in behavior when I run it on Knopflerfish #2.0.3. Upon investigation, I observed that Bundle.getResource() implementation on Knopflerfish does not use the parent class loader of the bundle even when I set org.osgi.framework.bootdelegation=*.

Here is a simple code that I used to test my theory:

public class Activator implements BundleActivator{

public void start(BundleContext context) throws Exception {
Class libClazz = context.getBundle().loadClass("sahoo.Library");
System.out.println("libClazz = " + libClazz);
URL libRes = context.getBundle().getResource("sahoo/Library.class");
System.out.println("libRes = " + libRes);
}
...

The above code prints non-null value for libClazz, but a null value for libResource. If Bundle.loadClass("sahoo.Library") could load the class, how could Bundle.getResource("sahoo/Library.class") return null? It works as expected in other OSGi implementations.

To ensure that sahoo.Library.class is available in the parent class loader, I wrote a Main class which creates a ClassLoader that has both the knopflerfish framework.jar and my library.jar in search path. I then use that classloader to launch knopflerfish.

Has anyone else faced similar issues? I think this is a serious bug in knopflerfish. I tried to get a confirmation by reporting it in their forum, but no luck. I also tried using the dev forum, but no difference. Is there a better way to ask them questions? I don't know. So I thought I would document what I observed.





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds