Hello, question regarding bootdelegation vs org.osgi.framework.system.packages.extra if I may:
Here my understanding ===================== 1. When I add additional packages to org.osgi.framework.system.packages.extra (using -runsystempackages in BndTools) , OSGI adds the packages to the system bundle and if a class X is not found in a bundle itself (either through its imports or in its private space), it tries to find this class using the system bundle. 2. If the system bundle exports the class, it will be found 3. This always worked fine using sun.misc ( I always use -runsystempackages) in other cases 4. However, when I try in corporate camel, I need to set the boot delegatio to =sun.misc as described here http://www.liferay.com/community/forums/-/message_boards/message/46779514 -runproperties: \ org.osgi.framework.bootdelegation=sun.misc Above works fine, and my Unsafe class is found. My question =========== A. Why wouldn¹t the camel bundle be able to find the Unsafe class that was exported from the system bundle, why do I have to add it the the JVM class loader via boot delegation? B. Is adding classes to the boot delegation dangerous ? I know its not considered best practice Thanks a lot in advance Frank Appendix ======== Links/Docu: ---------- http://wiki.osgi.org/wiki/Boot_Delegation http://moi.vonos.net/java/osgi-classloaders/ MiniApp: -------- @Component(immediate=true) public class RunCamelContext { private BundleContext context; @Activate public void activate(BundleContext context){ this.context = context; CamelContext camelContext = new OsgiDefaultCamelContext(context); System.out.println("Activated OSGI is working"); } } Error without Boot Delegation: ------------------------------ java.lang.NoClassDefFoundError: sun/misc/Unsafe at org.apache.camel.com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8 .getUnsafe(ConcurrentHashMapV8.java:4136) at org.apache.camel.com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8 .<clinit>(ConcurrentHashMapV8.java:4101) at org.apache.camel.com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHas hMap.<init>(ConcurrentLinkedHashMap.java:221) at org.apache.camel.com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHas hMap.<init>(ConcurrentLinkedHashMap.java:104) at org.apache.camel.com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHas hMap$Builder.build(ConcurrentLinkedHashMap.java:1598) at org.apache.camel.util.LRUCache.<init>(LRUCache.java:84) at aQute.launcher.Launcher.main(Launcher.java:90) Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe not found by org.apache.camel.camel-core [15] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation (BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.jav a:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(Bun dleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev