1 Reply Latest reply on Sep 15, 2010 4:18 AM by Ben Leedham

    Problem with using ehcache.

    Marcin Troscianczyk Newbie

      Hi,

       

      I've changed Fuse ESB from 4.2.0 to 4.3.0 and I've noticed that ehcache doesn't work. I'm using ehcache 1.6.2 installing from SpringSource Repository.

       

      With 4.2.0 version all works fine but with 4.3.0 version I'm getting exception:

       

      16:37:16,811 | ERROR | ExtenderThread-6 | ContextLoaderListener            | BundleApplicationContextListener   50 | 72 - org.springframework.osgi.extender - 1.2.0 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=cache-service.xml, config=osgibundle:/META-INF/spring/*.xml))

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManager' defined in URL bundleentry://185.fwk27140443/META-INF/spring/cache-service.xml: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: net/sf/ehcache/CacheManager

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)[60:org.springframework.context:3.0.3.RELEASE]

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[71:org.springframework.osgi.core:1.2.0]

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[71:org.springframework.osgi.core:1.2.0]

              at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[71:org.springframework.osgi.core:1.2.0]

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[71:org.springframework.osgi.core:1.2.0]

              at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)[72:org.springframework.osgi.extender:1.2.0]

              at java.lang.Thread.run(Thread.java:619)[:1.6.0_17]

      Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/CacheManager

              at java.lang.Class.getDeclaredMethods0(Native Method)[:1.6.0_17]

              at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)[:1.6.0_17]

              at java.lang.Class.getDeclaredMethods(Class.java:1791)[:1.6.0_17]

              at java.beans.Introspector$1.run(Introspector.java:1287)[:1.6.0_17]

              at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_17]

              at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1285)[:1.6.0_17]

              at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1151)[:1.6.0_17]

              at java.beans.Introspector.getBeanInfo(Introspector.java:402)[:1.6.0_17]

              at java.beans.Introspector.getBeanInfo(Introspector.java:168)[:1.6.0_17]

              at org.springframework.beans.CachedIntrospectionResults.(CachedIntrospectionResults.java:224)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1319)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)[59:org.springframework.beans:3.0.3.RELEASE]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)[59:org.springframework.beans:3.0.3.RELEASE]

              ... 13 more

      Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.CacheManager

              at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)[osgi-3.6.0.v20100517.jar:]

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)[osgi-3.6.0.v20100517.jar:]

              at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)[osgi-3.6.0.v20100517.jar:]

              at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)[osgi-3.6.0.v20100517.jar:]

              at java.lang.ClassLoader.loadClass(ClassLoader.java:248)[:1.6.0_17]

              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)[:1.6.0_17]

              ... 30 more

       

      This bundle is installed by droping xml file to deploy folder. It doesn't work either with felix and equinox container. How can I solve this problem?

       

      Cheers,

      Marcin

        • 1. Re: Problem with using ehcache.
          Ben Leedham Newbie

          Hi,

           

          I've been having the same error, it's taken me a while to find a way around it.

           

          I think it is to do with the fact that FUSE loads Spring bundles on boot, and the Spring-Context-Support bundle specifies net.sf.ehcache as an optional import, but because the Ehcache bundle isn't loaded at boot that optional import isn't satisfied, unles you do an osgi:refresh after installing your feature/bundle.

           

          Instead of doing an osgi:refresh I have added camel-cache to the front of the featuresBoot= line in the org.apache.karaf.features.cfg file.

           

          The camel-cache feature contains the Spring wrapped Ehcache bundle so the optional imports are satisfied at boot time.

           

          Hope this helps.