1 Reply Latest reply on Mar 26, 2014 3:50 AM by Andy Taylor

    Unable to Reload Rules for Second time

    Aravind K S Newbie

      I have an application which is using drools 5.5.0 final and i want to remove packages from knowledge base and add it again to reflect new changes. But for the first time i am able to remove and add it. Second time it is stopping at kbase.removeKnowledgePackage(packageName);. it is not giving any error also.


      This is my code

      rulelist will have the rules to be fired..


                         kbase = allRuleBases1.get("Kbase");

                          Collection<KnowledgePackage> packages = kbase


                              Iterator<KnowledgePackage> iter = packages.iterator();



                               KnowledgePackage kbPackage = iter.next();

                                String packageName = kbPackage.getName();

                                System.out.println("packageName = " + packageName);


                                System.out.println("removed packageName = " + packageName); }



                              ksession = allRuleBases.get("DefaultScenario");


                              //kbase = ksession.getKnowledgeBase();

                              kbuilder1 = KnowledgeBuilderFactory.newKnowledgeBuilder();


                              istream = new ByteArrayInputStream(ruleslist.getBytes());

                              kbuilder1.add(ResourceFactory.newInputStreamResource(istream), ResourceType.DRL);

                              errors = kbuilder1.getErrors();

                              if (errors.size() > 0) {

                                  for (KnowledgeBuilderError error : errors) {



                                  throw new IllegalArgumentException("Could not parse knowledge.");






                          //    while(kbase.getStatefulKnowledgeSessions().iterator()){



                                  ksession = kbase.getStatefulKnowledgeSessions().iterator().next();



                              allRuleBases.put("DefaultScenario", ksession);

                              allRuleBases1.put("Kbase", kbase);