11 Replies Latest reply on Aug 23, 2012 5:37 AM by Freeman(Yue) Fang

    Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy

    abhijit passi Newbie

      Hi,

       

      I am trying to use drools with fuse.

       

      below is my camel-context.xml file

      -


       

       

      -


      but on deployment getting the below exception.

       

       

      FuseESB:karaf@root> Exception in thread "SpringOsgiExtenderThread-12" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel-9': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find cl

      ass for bean with name 'droolsPolicy' defined in URL bundle://260.21:0/META-INF/spring/camel-context.xml; nested exception is java.lang.ClassNotFoundException: org.drools.camel.component.DroolsPolicy not found from bundle

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

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

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

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

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

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

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

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)

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

      Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class for bean with name 'droolsPolicy' defined in URL bundle://260.21:0/META-INF/spring/camel-context.xml; nested exception is java.lang.ClassNotFoundException: org.dro

      ols.camel.component.DroolsPolicy not found from bundle

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

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

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

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

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

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

              at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:140)

              at org.apache.camel.osgi.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:64)

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

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

              ... 14 more

      Caused by: java.lang.ClassNotFoundException: org.drools.camel.component.DroolsPolicy 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:248)

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

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

              at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1282)

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

              ... 23 more

      Caused by: java.lang.ClassNotFoundException: org.drools.camel.component.DroolsPolicy not found by drlexample

              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1467)

              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:73)

              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1850)

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

              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1745)

              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:929)

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

              ... 29 more

       

       

      -


       

      The corresponding org.drools.camel.component.DroolsPolicy jar file "drools-camel-5.2.0.M2.jar"  is present in the repository.

        • 1. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
          Freeman(Yue) Fang Master

          Hi,

           

          When you say "The corresponding org.drools.camel.component.DroolsPolicy jar file "drools-camel-5.2.0.M2.jar" is present in the repository." Do you mean the drools-camel-5.2.0.M2.jar bundle already get installed into OSGi container?

           

          Also you need ensure your camel router bundle already import package org.drools.camel.component.

           

          Freeman

          • 2. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
            abhijit passi Newbie

            Thanks for the reply.

             

            Yes,  the drools-camel-5.2.0.M2.jar bundle is installed into OSGi

             

            FuseESB:karaf@root> osgi:list |grep drools

            drools-camel (5.2.0.M2)

            drools-spring (5.2.0.M2)

             

             

            Can you guide for , how to import package org.drools.camel.component

            in camel router bundle.

            • 3. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
              Freeman(Yue) Fang Master

              Hi,

               

              How you build your camel router bundle?

              If you're using maven, you can use maven-bundle-plugin which you can configure the OSGi metadata header you want.

               

              As you have

               

              in your spring-dm configuration, I believe add maven-bundle-plugin could be able to add Import-Package org.drools.camel.component automatically.

               

              Freeman

              • 4. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                abhijit passi Newbie

                Yes , I did that as well... below is my plugin from pom.xml

                 

                 

                 

                Still getting the same exception

                • 5. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                  Freeman(Yue) Fang Master

                  Hi,

                   

                  Could you also post your customer camel router bundle OSGi metadata header?

                  You can use

                   

                  osgi:headers bundle_id_for_your_camel_router

                   

                  Freeman

                  • 6. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                    abhijit passi Newbie

                    Hi,

                     

                    I am able to solve the above error,of ClassNotFoundException for DroolsPolicy.

                     

                    After that now i am facing some new error like java.lang.NoSuchMethodError

                     

                    below is details of the error

                    *****************************************************************

                    ESB:karaf@root> Exception in thread "SpringOsgiExtenderThread-4" java.lang.NoSuchMethodError: org.apache.camel.model.BeanDefinition.setBeanType(Ljava/lang/Class;)V

                        at org.drools.camel.component.DroolsPolicy.augmentNodes(DroolsPolicy.java:119)

                        at org.drools.camel.component.DroolsPolicy.beforeWrap(DroolsPolicy.java:75)

                        at org.apache.camel.model.PolicyDefinition.createProcessor(PolicyDefinition.java:129)

                        at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:440)

                        at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:178)

                        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:871)

                        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:171)

                        at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:702)

                        at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1729)

                        at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1523)

                        at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1413)

                        at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:181)

                        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)

                        at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1381)

                        at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:230)

                        at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)

                        at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:242)

                        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)

                        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)

                        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)

                        at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)

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

                        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)

                    *****************************************************************

                     

                    I checked the BeanDefinition.class from org.apache.camel.model (camel-core-2.9.0.fuse-7-061.jar) file

                     

                    this class contains the method

                     

                    public void setBeanType(String beanType) {

                        this.beanType = beanType;

                      }

                     

                    Where as DroolsPolicy class from drools-camel-5.2.0.M2.jar is using

                     

                    beanDef.setBeanType(PreCxfrs.class);

                     

                     

                    So , I wanted to know , is there any updated version of camel-core-2.9.0.fuse-7-061.jar is present

                    • 7. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                      Willem Jiang Master

                      Camel 2.9.x doesn't has the BeanDefinition.setBeanType(Ljava/lang/Class;) method. It was add since Camel 2.10.0. You may need to upgrade the Camel version yourself.

                       

                      Willem

                      • 8. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                        abhijit passi Newbie

                        Hi,

                         

                        I have upgraded the camel version 2.10.0 with hot deployment of camel-core-2.10.0.jar

                         

                        but still getting the same exception , still it is referring the old camel-core-2.9.

                         

                        I tried with uninstalling the camel-core-2.9 , this results in failure of some other services.

                         

                         

                        Kindly suggest

                        • 9. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                          Freeman(Yue) Fang Master

                          Hi,

                           

                          I'd say upgrade to camel 2.10 yourself isn't that easy, a lot of dependencies need upgrade as well.

                           

                          I think you can start with install camel 2.10 features.xml and install camel features which you need from there.

                           

                          Freeman

                          • 10. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                            abhijit passi Newbie

                            Hi,

                             

                            I tried to install camel-core-2.10 with the below command

                             

                            FuseESB:karaf@root> features:addurl mvn:org.apache.camel.karaf/apache-camel/2.10.0/xml/features

                             

                            FuseESB:karaf@root> features:list |grep camel-core

                            camel-core                            camel-2.9.0.fuse-7-061

                            camel-core                            camel-2.10.0

                            ************************************************************

                            But on installation getting the below error

                             

                            FuseESB:karaf@root> features:install camel-core

                            Error executing command: Can not resolve feature:

                            Unsatisfied requirement(s):

                            -


                               package:(&(package=jline.console.completer)(version>=2.7.0)(!(version>=3.0.0)))

                                  camel-karaf-commands

                            FuseESB:karaf@root>

                            • 11. Re: Drools with fuse : Getting ClassNotFoundException: for DroolsPolicy
                              Freeman(Yue) Fang Master

                              Hi,

                               

                              As I mentioned, a lot of dependencies need get upgraded, obviously jline.console.completer is one of them, but definitely not the only one.

                               

                              jline.console.complete is from karaf.shell.console bundle and jline.console.complete 2.7 need a higher version of karaf.

                               

                              Which means it's hard for you to deploy camel 2.10 in current FUSE ESB 7.0.1.

                              FUSE ESB 7.1 is aiming to support Camel 2.10 and CXF 2.6 OOB, you may need wait for FUSE ESB 7.1.

                               

                              Freeman