Hello all
 
I am using Drools4.0.3
I have a J2EE application that I am running  on Tomcat.
I am using a singleton class in which I am doing the following steps in the constructor :
 
PackageBuilderConfiguration pkgBuilderCfg = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration) pkgBuilderCfg.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.JANINO );
builder = new PackageBuilder(pkgBuilderCfg);
ruleBase = RuleBaseFactory.newRuleBase();
 
Also I am using a method in the same class to validate the inputs which is as follows:
 
private void validateXML() throws Exception
 {
  String drlStr = null;
  InputStreamReader drl = null;
  File ruleFile = new File(this.fileName);
  long curLMTime = ruleFile.lastModified();
  if(!(curLMTime == lmdTimeForXML))
  {
   lmdTimeForXML = curLMTime;
   if(strReader != null) {
    strReader.close();
    strReader = null;
   }
   if(pkg != null){
    String packageName = (ruleBase.getPackage("jbossrules")).getName();
    if(packageName != null && packageName.equals("jbossrules")){
     Rule[] rules =  (ruleBase.getPackage("jbossrules")).getRules();
     if(rules != null){
      for (int i=0; i<rules.length; i++){
       String ruleName = rules[i].getName();
       try {
        ruleBase.removeRule(packageName,ruleName);
       }catch(NullPointerException ne){
       }
      }
     }
    }
   }
   try {
    drl =new InputStreamReader(new FileInputStream(this.fileName));
    drlStr = this.getInputStreamAsString(drl);
    strReader = new StringReader(drlStr);
    builder.addPackageFromXml(strReader);
    pkg = builder.getPackage();
    ruleBase.addPackage(pkg);
   } catch (IOException e) {
    e.printStackTrace();
    log.error("*********Can not create inputstrea************", e);
    lmdTimeForXML = 0;
    throw e;
    //removeRules();
   }catch (Exception e) {
    e.printStackTrace();
    log.error("*********CAN NOT CREATE THE RULE BASE INSTANCE************", e);
    lmdTimeForXML = 0;
    throw e;
    //removeRules();
   }finally {
    try {
     if(drl != null) {
      drl.close();
     }
    } catch (IOException e) {
     e.printStackTrace();
     log.error("*********Can not create inputstrea************", e);
    }
   }
  }
  StatefulSession session = ruleBase.newStatefulSession();
  session.insert(this.beanObj);
  session.setGlobal("response",this.response);
  if(this.assertObjArr != null && this.assertObjArr.length > 0)
  {
   for(int i=0; i<this.assertObjArr.length; i++)
    session.insert(this.assertObjArr[i]);
  }
  
  Agenda agenda=session.getAgenda();
  AgendaGroup agendagroup=agenda.getAgendaGroup(this.getMethodName());
                session.setFocus(agendagroup);
  session.fireAllRules();
  ResponseBean res = (ResponseBean)session.getGlobal("response");
  this.setResponse(res);
  session.clearAgenda();
  session.setGlobal("response",null);
  session.dispose();
  session = null;  
 }
 
Now when I am deploying any wrong rule,it gets stored in the memory.If again I am deploying the rules then the previous wrong rules are not deleting.
Please suggest me how can I overcome this problem?
 
 
With Regards
Prateek

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