Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Won't Fix
-
2.23.1
-
None
-
None
-
Unknown
Description
I have very simple OSGI bundle, which uses just camel-core.
When I run it, an exception is thrown:
20:14:31.684 [Camel Thread #0 - LRUCacheFactory] DEBUG org.apache.camel.util.LRUCacheFactory - Warming up LRUCache ... Exception in thread "Camel Thread #0 - LRUCacheFactory" java.lang.NoClassDefFoundError: sun/misc/Unsafe at org.apache.camel.com.github.benmanes.caffeine.base.UnsafeAccess.load(UnsafeAccess.java:68) at org.apache.camel.com.github.benmanes.caffeine.base.UnsafeAccess.<clinit>(UnsafeAccess.java:42) at org.apache.camel.com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef.<clinit>(BoundedLocalCache.java:3487) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.apache.camel.com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(Unknown Source) at org.apache.camel.com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.<init>(BoundedLocalCache.java:3043) at org.apache.camel.com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.<init>(BoundedLocalCache.java:3039) at org.apache.camel.com.github.benmanes.caffeine.cache.Caffeine.build(Caffeine.java:926) at org.apache.camel.util.LRUCache.<init>(LRUCache.java:124) at org.apache.camel.util.LRUCache.<init>(LRUCache.java:92) at org.apache.camel.util.LRUCache.<init>(LRUCache.java:79) at org.apache.camel.util.LRUCache.<init>(LRUCache.java:66) at org.apache.camel.util.LRUCacheFactory.newLRUCache(LRUCacheFactory.java:89) at org.apache.camel.util.LRUCacheFactory.lambda$warmUp$0(LRUCacheFactory.java:66) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe cannot be found by org.apache.camel.camel-core_2.23.1 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:511) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:414) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:153) at java.lang.ClassLoader.loadClass(Unknown Source) ... 18 more ! Failed to start bundle adapters.service-0.0.1, exception activator error Could not initialize class org.apache.camel.com.github.benmanes.caffeine.cache.BoundedLocalCache from: sun.reflect.NativeConstructorAccessorImpl:newInstance0#-2 org.osgi.framework.BundleException: Exception in adapters.service.Activator.start() of bundle adapters.service. at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:803) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:732) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1005) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:357) at org.eclipse.osgi.container.Module.doStart(Module.java:584) at org.eclipse.osgi.container.Module.start(Module.java:452) at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:431) at aQute.launcher.Launcher.startBundles(Launcher.java:519) at aQute.launcher.Launcher.activate(Launcher.java:425) at aQute.launcher.Launcher.run(Launcher.java:303) at aQute.launcher.Launcher.main(Launcher.java:149) Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.camel.com.github.benmanes.caffeine.cache.BoundedLocalCache at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.apache.camel.com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(Unknown Source) at org.apache.camel.com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.<init>(BoundedLocalCache.java:3043) at org.apache.camel.com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.<init>(BoundedLocalCache.java:3039) at org.apache.camel.com.github.benmanes.caffeine.cache.Caffeine.build(Caffeine.java:926) at org.apache.camel.util.LRUCache.<init>(LRUCache.java:124) at org.apache.camel.util.LRUWeakCache.<init>(LRUWeakCache.java:61) at org.apache.camel.util.LRUWeakCache.<init>(LRUWeakCache.java:57) at org.apache.camel.util.LRUCacheFactory.newLRUWeakCache(LRUCacheFactory.java:152) at org.apache.camel.management.MBeanInfoAssembler.start(MBeanInfoAssembler.java:74) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) at org.apache.camel.management.DefaultManagementMBeanAssembler.doStart(DefaultManagementMBeanAssembler.java:121) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:60) at org.apache.camel.management.DefaultManagementAgent.doStart(DefaultManagementAgent.java:395) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) at org.apache.camel.management.DefaultManagementStrategy.doStartManagementStrategy(DefaultManagementStrategy.java:253) at org.apache.camel.management.ManagedManagementStrategy.doStart(ManagedManagementStrategy.java:206) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3342) at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3248) at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3244) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3267) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3244) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3160) at adapters.service.Activator.start(Activator.java:28) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:782) at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:775) ... 10 more
Camel-core bundle should Import sun.misc package
Until this bug is resolved, a workaround is to add "-runproperties: org.osgi.framework.bootdelegation="sun.misc"" to bnd.bnd file