4 Replies Latest reply on Apr 23, 2010 3:44 AM by fsalceda

    camel-bundle example ClassNotFoundException

    fsalceda

      I'm following the tutorial with the last release of Fuse-ESB (apache-servicemix-4.2.0-fuse-01-00). When i try to start the "camel-bundle"  it crashes with:

       

      -


      Exception in thread "SpringOsgiExtenderThread-82" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camelContext': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class for bean with name 'myTransform' defined in URL bundleentry://200.fwk27334345/META-INF/spring/camel-context.xml; nested exception is java.lang.ClassNotFoundException: org.fusesource.example.MyTransform not found from bundle

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

           at java.security.AccessController.doPrivileged(Native Method)

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)

           at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)

           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)

           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)

           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)

           at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)

           at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:947)

           at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:701)

           at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1500(AbstractDelegatedExecutionApplicationContext.java:69)

           at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:351)

           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:136)

           at java.lang.Thread.run(Thread.java:595)

      Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class for bean with name 'myTransform' defined in URL bundleentry://200.fwk27334345/META-INF/spring/camel-context.xml; nested exception is java.lang.ClassNotFoundException: org.fusesource.example.MyTransform not found from bundle

           at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)

           at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)

           at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:222)

           at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:937)

           at org.apache.camel.spring.CamelContextFactoryBean.getBeanForType(CamelContextFactoryBean.java:570)

           at org.apache.camel.spring.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:192)

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)

           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)

           ... 18 more

      Caused by: java.lang.ClassNotFoundException: org.fusesource.example.MyTransform not found from bundle

           at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)

           at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)

           at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)

           at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)

           ... 26 more

      Caused by: java.lang.ClassNotFoundException: org.fusesource.example.MyTransform

           at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:448)

           at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)

           at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)

           at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)

           at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)

           at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1193)

           at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)

           ... 31 more

      -


       

      Why the ClassLoader don't find MyTransformer class??

       

      THX

        • 1. Re: camel-bundle example ClassNotFoundException
          njiang

          Can you check if your camel-bundle has the class "org.fusesource.example.MyTransform"?

           

          BTW I didn't found the description of the camel-bundle from the tutorial link that you showed to me.

          • 2. Re: camel-bundle example ClassNotFoundException
            fsalceda

            The camel-bundle example that I mean is exactly this .

             

            And yes, the MyTransformer.class exists and alsoo in the generated jar.

            • 3. Re: camel-bundle example ClassNotFoundException
              njiang

              After went through the tutorial, I can start the bundle without any issue with new installation of Fuse ESB  4.2.0-fuse.

              But after I checked the camel-bundle's MANIFEST.MF, I found something was wrong.

               

              The camel-bundle should not import the "com.fusesource.example" package when it export the package. If you have more than one bundle which export the same "com.fusesource.example" installed , it may cause the trouble that you met, as your camel-bundle may import the package which doesn't have the MyTransform.class.

               

              To avoid this issue, you need to update the camel-bundle pom.xml by changing the below line in the org.apache.felix maven-bundle-plugin to ignore the package.

              <Import-Package>!org.fusesource.example,*</Import-Package>
              

               

              • 4. Re: camel-bundle example ClassNotFoundException
                fsalceda

                Thanks a lot. Now it works. But, why does it happen? I mean after excluding the package that includes MyTransformer class, the classloader can find it.

                 

                Thx again.