12 Replies Latest reply on Apr 4, 2011 11:22 AM by roar109

    How can access Guvnor rules from ESB Service?

    roar109

      Ok, I see the samples/quickstarts/business_ruleservice_ruleAgent example, but in the example use a properties file  with the especification of a .drl file. I make a proyect with a service and a brmsdeployedrules.properties file, this is the prop file:

       

       

      newInstance=True
      url=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.kaf.tests/LATEST
      name=guvnorAgent
      enableBasicAuthentication=True
      username=admin
      password=admin
      

       

       

      I have a esbserver-4.9 all include with guvnor war inside the esb server, version 5.1 of guvnor, with default authentification this is take any username and login.

       

      All work's "fine", but when I try to invoke the service throw a 401 error, this is the stack trace:

       

       

      21:26:01,758 ERROR [LogAgentEventListener] Agent [guvnorAgent] Message [KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage  ]
      java.lang.RuntimeException: KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage  
                at org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:664)
                at org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:889)
                at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:704)
                at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:584)
                at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:185)
                at org.jboss.internal.soa.esb.services.rules.DroolsRuleBaseHelper.createRuleAgent(DroolsRuleBaseHelper.java:228)
                at org.jboss.internal.soa.esb.services.rules.DroolsRuleService.getRuleBaseStateForRuleAgent(DroolsRuleService.java:332)
                at org.jboss.internal.soa.esb.services.rules.DroolsRuleService.executeStatelessRulesFromRuleAgent(DroolsRuleService.java:115)
                at org.jboss.internal.soa.esb.services.rules.RuleServiceCallHelper.executeStateless(RuleServiceCallHelper.java:278)
                at org.jboss.internal.soa.esb.services.rules.RuleServiceCallHelper.executeRulesService(RuleServiceCallHelper.java:262)
                at org.jboss.soa.esb.actions.BusinessRulesProcessor.executeRulesService(BusinessRulesProcessor.java:140)
                at org.jboss.soa.esb.actions.BusinessRulesProcessor.process(BusinessRulesProcessor.java:121)
                at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:649)
                at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:603)
                at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:433)
                at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                at java.lang.Thread.run(Thread.java:680)
      Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.kaf.tests/LATEST
                at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
                at org.drools.io.impl.UrlResource.grabStream(UrlResource.java:210)
                at org.drools.io.impl.UrlResource.getInputStream(UrlResource.java:146)
                at org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:652)
                ... 18 more
      21:26:01,760 ERROR [LogAgentEventListener] Agent [guvnorAgent] Message [KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage  ]
      java.lang.RuntimeException: KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage  
                at org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:914)
                at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:704)
                at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:584)
                at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:185)
                at org.jboss.internal.soa.esb.services.rules.DroolsRuleBaseHelper.createRuleAgent(DroolsRuleBaseHelper.java:228)
                at org.jboss.internal.soa.esb.services.rules.DroolsRuleService.getRuleBaseStateForRuleAgent(DroolsRuleService.java:332)
                at org.jboss.internal.soa.esb.services.rules.DroolsRuleService.executeStatelessRulesFromRuleAgent(DroolsRuleService.java:115)
                at org.jboss.internal.soa.esb.services.rules.RuleServiceCallHelper.executeStateless(RuleServiceCallHelper.java:278)
                at org.jboss.internal.soa.esb.services.rules.RuleServiceCallHelper.executeRulesService(RuleServiceCallHelper.java:262)
                at org.jboss.soa.esb.actions.BusinessRulesProcessor.executeRulesService(BusinessRulesProcessor.java:140)
                at org.jboss.soa.esb.actions.BusinessRulesProcessor.process(BusinessRulesProcessor.java:121)
                at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:649)
                at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:603)
                at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:433)
                at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                at java.lang.Thread.run(Thread.java:680)
      Caused by: java.lang.NullPointerException
                at org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:906)
                ... 17 more
      
      

       

       

      In the documentation I don't see anything like that, in theory that error says the authentification are wrong but it should work, algo I attach the jbosses.xml file and components.xml file from guvnor.

       

      Any ideas or another way access guvnor rules?

        • 1. How can access Guvnor rules from ESB Service?
          roar109

          Anyone knows how can access rules in guvnor from a esb service?

          • 2. How can access Guvnor rules from ESB Service?
            kcbabo

            Are you deploying Guvnor to the stand-alone ESB server?  I've never tried this, so I can't confirm whether it should work.  The ESB server is a custom fit AS 4.x container for ESB.  Have you tried with Guvnor and the ESB distribution deployed on AS 5? Another thing you could try is using the rule agent config from a stand-alone Java application and verify that it works.  That would help narrow in on whether it's a client or server configuration issue.

            • 3. Re: How can access Guvnor rules from ESB Service?
              roar109

              I follow your advice and now use Jboss As 5.1 with jbossesb4.9, drools guvnor 5.1, I did a stand alone client to consume guvnor pkg's, and the properties with the url username, so on; and works just how supuse to work, execute the rule ok.

               

              So.. Guvnor is with the authentication running ok, the stand alone application can access to pkg's with properties file with the authentication in it ok.

              So I don't know if the action who calls the guvnor is wrong:

               

               

              <action class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="GuvnorTest">
                   <property name="ruleAgentProperties" value="/ruleAgent.properties"/>
                   <property name="object-paths">
                        <object-path esb="body.Cat"/>
                   </property>
              </action>
              
              

              Complete file is attached on the jbossesb.xml in the post OP.

              • 4. How can access Guvnor rules from ESB Service?
                kcbabo

                OK, so it works in the stand-alone client case.  Did it work with BusinessRulesProcessor in ESB when you deployed Guvnor to AS 5.1?

                • 5. Re: How can access Guvnor rules from ESB Service?
                  roar109

                  No, I did the configuration showed before  and throw the exception, do you know if that version of esb works with the authentication on guvnor?

                  • 6. How can access Guvnor rules from ESB Service?
                    kcbabo

                    The code is definitely there to read this config and supply it to the KnowledgeAgent.  The code which handles this is in services/jbrules ... DroolsRuleAgentHelper and DroolsRuleBaseHelper.  I have not tested the authentication personally, so I can't say defintively that it definitely works, just that I have no reason to believe it would not work based on what I see in the code.

                    • 7. Re: How can access Guvnor rules from ESB Service?
                      roar109

                      Yeah I know if is there is because work's, only in this specific case I really don't know what happen, let me check that classes and see the stacktrace to look for something i miss.

                       

                      You have some example using drools?

                      • 8. Re: How can access Guvnor rules from ESB Service?
                        roar109

                        I did a little debugging and this is the result:

                        In prop file I put this:

                         

                        url=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.kaf.petstore/LATEST
                        enableBasicAuthentication=true
                        username=admin
                        password=
                        name=petsAge
                        newInstance=true
                        poll=30
                        

                         

                        But when the DroolsRuleAgentHelper converts that to change-set, change to this:

                         

                        <change-set xmlns="http://drools.org/drools-5.0/change-set" 
                        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" 
                        xs:schemaLocation="http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd">
                        <add>
                        <resource source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com.kaf.petstore/LATEST" 
                        type="PKG" basicAuthentication="true" username="admin" password=""/>
                        </add>
                        </change-set>
                        

                         

                        I did before a change-set and the propertie basicAuthentication should be "enabled" not "true". If a test a change-set.xml with the basicAuthentication propertie in "true" throw the IOException.

                         

                        If I did a console test with change-set.xml with basicAuthentication="true" throw the exception but if I change to basicAuthentication="enabled" works.

                         

                        If I use enableBasicAuthentication=enabled, the change-set.xml propertie change to  basicAuthentication="false" is obvious becuse the  DroolsRuleAgentHelper code is:

                         

                         

                        // BASIC Auth
                               String eba = source_props.getProperty(RuleAgent.ENABLE_BASIC_AUTHENTICATION);
                               if (eba != null)
                               {
                                     basicAuthentication = Boolean.valueOf(eba);
                                     if (basicAuthentication.booleanValue())
                                     {
                                           username = source_props.getProperty(RuleAgent.USER_NAME);
                                           password = source_props.getProperty(RuleAgent.PASSWORD);
                                      }
                                }
                        
                        

                         

                        So whats next here...? jira?

                        • 9. Re: How can access Guvnor rules from ESB Service?
                          kcbabo


                          Hey Hector,

                           

                          Yep, you nailed it.  Thanks for digging and finding this bug.  If you could submit a JIRA, that would be great.


                          As a workaround, it looks like you should be able to pass in a changeset directly as the ruleAgentProperties parameter instead of a properties file, e.g.:

                           

                          <action class="org.jboss.soa.esb.actions.BusinessRulesProcessor" name="GuvnorTest">

                               <property name="ruleAgentProperties" value="/my-change-set.xml"/>

                               <property name="object-paths">

                                <object-path esb="body.Cat"/>

                               </property>

                              </action>

                           

                          I tested this with the ruleAgent quickstart and it worked fine.

                           

                          cheers,

                          keith

                          • 10. How can access Guvnor rules from ESB Service?
                            roar109

                            Every time I try to make the jira ticket and get this:

                            "java.io.IOException: No space left on device"

                            Any ideas or server issues in this days?

                            • 11. How can access Guvnor rules from ESB Service?
                              kconner

                              Can you tell me which version of the ESB server/SOA server you are using?  You mentioned earlier that it was 4.9, is this from the 4.9 release or did you build from the CP branch?

                               

                              The reason I ask is that it sounds like the following issues https://issues.jboss.org/browse/JBESB-3563 and https://issues.jboss.org/browse/SOA-2842.

                               

                              Thanks,

                              Kev

                              • 12. How can access Guvnor rules from ESB Service?
                                roar109

                                I use the ESB server 4.9 from the downloads page http://www.jboss.org/jbossesb/downloads the jbossesb-4.9.zip and jbossesb-4.9-src.zip it is the 2 zip I use for test and see the source code.

                                 

                                I saw the issues on the links you provide and is the same error, so I see in the 4.9 CP1 is fixed, that code is available where?