13 Replies Latest reply on Apr 22, 2013 9:25 PM by ffang

    Integration with Drools

    mpalvankar

      I have the rules stored in "Guvnor -5.5.0.Final" running on Tomcat.

       

      I have a web service running on FUSE (apache-servicemix-4.4.1-fuse-00-08). I need to fetch the compiled rule .PKG from Guvnor and execute the same from this service.

       

      To do this I can not use the drools (org.apache.servicemix.bundles.drools) that is shipped with FUSE and I need to deploy drools-core (version 5.5.0.Final) on FUSE.

       

      I am facing below issues deploying drools-core (version 5.5.0.Final).

       

      I deployed

      1. com.google.protobuf/protobuf-java/2.5.0

      2. com.sun.xml.bind/jaxb-osgi/2.2.6

      3. javax.xml.bind/jaxb-api-osgi/2.2.7

      4. org.drools/drools-core/5.5.0.Final

       

      Has anyone tried deploying org.drools/drools-core/5.5.0.Final to FUSE 4.4.1

       

      Appreciate help.

        • 1. Re: Integration with Drools
          ffang

          Hi,

           

          Drools has some issues in OSGi container, so that servicemix re-wrap it as OSGi bundle, please try the one here[1]

           

          http://repo2.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.drools/5.5.0.Final_1/

           

          Freeman

          • 2. Re: Integration with Drools
            mpalvankar

            Thanks Freeman.

             

            I was able to deploy org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools/5.5.0.Final_1 successfully to FUSE 4.4.1

             

            But there is another issue. My service on FUSE ESB has following code to access and execute a rule.

             

            private void executeRuleWithKAgent(){

                       

                      KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "SecurityAgent" );

                      kagent.applyChangeSet( ResourceFactory.newClassPathResource( "securityValidate2.xml" ) );

                     KnowledgeBase kbase = kagent.getKnowledgeBase();

                      

                     StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                      PortfolioHolding vo = new PortfolioHolding();

                      vo.setSecurityId("TEST");

                       

                      ksession.insert(vo);

                      ksession.fireAllRules();

                      for (Object o : ksession.getObjects()) {

                           if (o instanceof PortfolioHolding) {

                                System.out.println("----


            "+((PortfolioHolding) o).getResultMessage());

                           }

                      }

                      

                     kagent.dispose();

                      

                      System.out.println("----***-----DONE");

                 }

             

             

             

            This requires jaxb-xjc as the code gives compilation errors as:

            could not parse error message: org\drools\builder\KnowledgeBuilderFactoryService.java(org\drools\builder:KnowledgeBuilderFactoryService.java):

            24: package com.sun.tools.xjc does not exist

            import com.sun.tools.xjc.Options;

             

            Hence I tried to deploy org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/2.2.6_1

             

            This deployment fails as it requires package

            com.sun.istack (version=2.2.0)

             

            Appreciate a quick help on this issue.

            • 3. Re: Integration with Drools
              ffang

              Hi,

               

              The error message indicates you should install another bundle which export package com.sun.istack (version=2.2.0), this is actually  exposed by the jaxb-impl bundle, servicemix also has a wrapper for it.

               

              Freeman

              • 4. Re: Integration with Drools
                mpalvankar

                Once again thanks Freeman.

                 

                But unfortunately I have some new problem. Now the deployment of org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/2.2.6_1 fails for constraint

                 

                Unresolved constraint in bundle org.apache.servicemix.bundles.jaxb-xjc : Unable to resolve 225.0: missing requirement package; (package=com.sun.source.tree)

                 

                I looked for OSGi wrapper for a jar that's exporting com.sun.source.tree, ut I have not been able to find any OSGi bundle exporting package com.sun.source.tree

                 

                Any clue for resolving this error. By the way I am using "apache-servicemix-4.4.1-fuse-00-08".

                 

                Thank you so much for prompt responses. This forum really rocks.

                • 5. Re: Integration with Drools
                  ffang

                  Hi,

                   

                  Though Servicemix provide lots of bundles, but it can't provide all necessary bundles for a specific user project(sometimes also due to license issue), so you probably still need create necessary bundles yourself.

                   

                  Freeman

                  • 6. Re: Integration with Drools
                    mpalvankar

                    Thanks Freeman.

                     

                    This package (com.sun.source.tree) is available in tools.jar a JDK internal package. Repackaging tools.jar will not be viable option.

                     

                    I also read that JDK internal packages can be made available by setting org.osgi.framework.system.packages.extra in etc\custom.properties file.

                     

                    Please correct me if I am wrong or if I am missing any information.

                    • 7. Re: Integration with Drools
                      ffang

                      Hi,

                       

                      Yes, you can add it in org.osgi.framework.system.packages.extra property

                       

                      Freeman

                      • 8. Re: Integration with Drools
                        mpalvankar

                        Thanks Freeman.

                         

                        After updating the properties file with required JDK package, I was able to resolve the deployment issues for org.apache.servicemix.bundles.drools/5.5.0.Final_1.

                         

                        But now when I deploy a my application / service that uses drools packages, I get below error:

                         

                        Unable to resolve 239.0: missing requirement package; (&(package=org.mvel2)(version>=2.1.0)(!(version>=3.0.0)))

                         

                        I checked below things:

                         

                        1] the bundle org.apache.servicemix.bundles.drools version 5.5.0.Final_1 contains org.mvel2 (2.1.8 Final)

                         

                        2] My pom file has dependency of org.apache.servicemix.bundles.drools version 5.5.0.Final_1 (I have attached my application pom file)

                         

                         

                        I am not able understand the above error. Is there anything that I am missing.

                         

                        Any help on the same is appreciated.

                        • 9. Re: Integration with Drools
                          ffang

                          Hi,

                           

                          No, org.apache.servicemix.bundles.drools doesn't export org.mvel2 package, you need install mvel2 bundle yourself.

                           

                          Freeman

                          • 10. Re: Integration with Drools
                            mpalvankar

                            There is no servicemix bundle for mvel2 version 2.1.3.Final. The highest version thats available is org.apache.servicemix.bundles.mvel/2.0.18_3.

                             

                            I tried wrapping mvel2 2.1.3.Final and deploying the same but this version 2.1.3.Final imports  mvel2 2.1.0 and hence I may to wrap mvel2 2.1.0 as osgi bundle and deploy the same to resolve this constraint issue

                             

                            Can I wrap two jars in one osgi bundle or do I have create two separate osgi bundles for version 2.1.0 and 2.1.3.Final

                            • 11. Re: Integration with Drools
                              ffang

                              Hi,

                              mvel2 2.1.3.Final is already a OSGi bundle so that you needn't wrap it anymore, just do

                               

                              osgi:install -s mvn:org.mvel/mvel2/2.1.3.Final

                               

                              should be fine.

                               

                              Freeman

                              • 12. Re: Integration with Drools
                                mpalvankar

                                Thanks Freeman for instant responses. I was able resolve all the issues.

                                 

                                I am also able execute my service on FUSE ESB which retrieves a rule from Guvnor running on Tomcat and execute the same.

                                 

                                Putting down the summary, in case anyone wants to try similar use case.

                                 

                                I installed following bundles to retrieve a rule from Guvnor and execute a rule.

                                 

                                1. org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools/5.5.0.Final_1

                                2. org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/2.2.6_1

                                3. org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/2.2.6_1

                                4. org.mvel/mvel2/2.1.3.Final

                                 

                                As I have said in my earlier posts, this forum really rocks.

                                • 13. Re: Integration with Drools
                                  ffang

                                  Hi,

                                   

                                  Thanks for this positive feedback and sharing your solutions.

                                   

                                  Freeman