[rules-users] help on drools guvnor
Stephen Masters
stephen.masters at me.com
Wed Jul 17 09:19:21 EDT 2013
Have you tested that the rules fire when you load them as DRL?
It would probably be worth showing us what EmployeeMap looks like and the rule which you expect to fire if there is an EmployeeMap in working memory.
The Drools version would also be useful.
Steve
On 17 Jul 2013, at 14:04, pritha.ghosh at wipro.com wrote:
> Hi,
>
> I am not able to run rules from .pkg resources.
>
> Knowledgesession is getting populated with package and rules inside the packages but when I am firing ksession.fireAllRules(); no rules are getting executed.
>
> Below is my program
>
> final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
>
> // Use this line if calling rule defined using guvnor package
> org.drools.io.impl.UrlResource urlResource;
> try {
> urlResource = (org.drools.io.impl.UrlResource) org.drools.io.ResourceFactory
> .newUrlResource(new java.net.URL("http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/OBSPOC/OBSSNAP/OBSPOC_OBSSNAP.pkg"));
>
>
> urlResource.setBasicAuthentication("enabled");
> urlResource.setUsername("admin");
> urlResource.setPassword("admin");
> kbuilder.add(urlResource,ResourceType.PKG);
> }
> catch (MalformedURLException e) {
> System.out.println("malformed URL");
> e.printStackTrace();
> }
> catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> // create the knowledge base
> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
>
>
>
>
> // Check the builder for errors
> if (kbuilder.hasErrors()) {
> System.out.println(kbuilder.getErrors().toString() + "********");
> throw new RuntimeException("Unable to compile the rule file.");
> }else{
> System.out.println(".....Rule File is Read Successfully....");
> }
>
> // get the compiled packages (which are serializable)
> final Collection pkgs = kbuilder
> .getKnowledgePackages();
>
> // add the packages to a knowledgebase (deploy the knowledge packages).
> // final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
> kbase.addKnowledgePackages(pkgs);
>
>
> final StatefulKnowledgeSession ksession = kbase
> .newStatefulKnowledgeSession();
>
> ksession.addEventListener(new DebugAgendaEventListener());
> ksession.addEventListener(new DebugWorkingMemoryEventListener());
>
> EmployeeMap employeeMap = new EmployeeMap();
> employeeMap.setEmployeeCountry("INDIA");
> employeeMap.setEmployeeID(1);
> employeeMap.setEmployeeName("USERP");
>
> ksession.insert(employeeMap);
> ksession.fireAllRules();
>
>
> ksession.dispose();
>
>
> Thanks,
> Pritha
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> www.wipro.com
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130717/6d327e7a/attachment-0001.html
More information about the rules-users
mailing list