NoClassDefFoundError even though package imported
dustin_dustin.schultz Feb 7, 2012 5:49 PMHi,
I keep getting a runtime NoClassDefFoundError error even though the package/class that it says it can't find is imported into the necessary bundle:
The bundle is question requires Apache Java Caching System (JCS). JCS in turn depends on an old concurrent library by Doug Lea. Both bundles are Active on the bus:
[ 222] [Active ] [ ] [ ] [ 60] wrap_mvn_jcs_jcs_1.3 (0) [ 234] [Active ] [ ] [ ] [ 60] Concurrent (1.3.4)
The bundle that throws the error, properly imports both packages
wrap_mvn_jcs_jcs_1.3 (222): org.apache.jcs; version="0.0.0" wrap_mvn_jcs_jcs_1.3 (222): org.apache.jcs.access.exception; version="0.0.0" wrap_mvn_jcs_jcs_1.3 (222): org.apache.jcs.engine.control; version="0.0.0" Concurrent (234): EDU.oswego.cs.dl.util.concurrent; version="1.3.4"
However, when the Spring ApplicationContext is started and one of the beans runs an @AfterProperties method, it throws:
Exception in thread "SpringOsgiExtenderThread-29" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachingService': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: EDU/oswego/cs/dl/util/concurrent/Channel at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355) at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320) at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.NoClassDefFoundError: EDU/oswego/cs/dl/util/concurrent/Channel at org.apache.jcs.engine.control.CompositeCacheManager.configure(CompositeCacheManager.java:303) at org.apache.jcs.engine.control.CompositeCacheManager.configure(CompositeCacheManager.java:258) at edu.utah.further.core.util.cache.CachingServiceJcsImpl.afterPropertiesSet(CachingServiceJcsImpl.java:86) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130) ... 16 more Caused by: java.lang.ClassNotFoundException: EDU.oswego.cs.dl.util.concurrent.Channel at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 26 more
I've verified that the actual Channel class is included in the jar .. just for my sanity.
Looking at the JCS code, at line 303, it calls this method statically
ThreadPoolManager.setProps( props )
ThreadPoolManager imports EDU.oswego.cs.dl.util.concurrent.Channel
I've tried a fragment bundle attached to JCS to expand it's classpath - that didn't work either.
The only way I could get it to work was to embed concurrent in JCS.
Is there a bug with ServiceMix 4.4? This worked previously on ServiceMix 4.2.
Thanks,
Dustin