Hello, I am using Karaf 3.0.3 on JDK 1.7, I noticed a behaviour by Aries Blueprint which seems a little odd to me. We have created a bundle which gets initialized/activated using blueprint, within the blueprint.xml we have a bean with init-method defined to it. I noticed that the classloader used is sun.misc.Launcher$AppClassLoader instead of the usual bundle specific classloader. Since this wasnt a bundle specific classloader it failed to resolve the dependencies available to it from the other bundles. Sample xml used for the blueprint definition is below
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm=" http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd "> <bean id="initBean" class="com.example.KickStarter" init-method="init"/> </blueprint> KickStarter.java public void init() { System.err.println( " Classloader " + Thread.currentThread().getContextClassLoader() ); } output :- Classloader sun.misc.Launcher$AppClassLoader@74184b3b For the code to resolve the dependencies i had to manually set the classloader using Bundle bundle1 = FrameworkUtil.getBundle( KickStarter.class ); ClassLoader newCL = bundle1.adapt(BundleWiring.class).getClassLoader(); My question to the group is whether using of Launcher classloader is normal or should it have been bundle aware classloader ? Thank you! Regards, -Yogesh
