0 Replies Latest reply on Jan 11, 2008 9:41 AM by shivakatula

    java.lang.NullPointerException at at org.drools.rule.builder

    shivakatula

      Hi,

      I have the following in drl file.

      package com.framework.service.remote.rules;
      
      import com.framework.service.util.FSSInputOutputVO;
      import com.framework.service.EssRuleConditionService;
      import com.framework.service.util.CurrentLeg;
      import com.framework.service.util.NextLeg;
      import com.framework.service.util.PreviousLeg;
      import com.framework.service.util.SecondNextLeg;
      import com.framework.service.util.SecondPreviousLeg;
      import java.util.ArrayList;
      import java.util.List;
      import java.lang.Boolean;
      
      function List depStationFun68307cu() {
       EssRuleConditionService essRuleConditionService = new EssRuleConditionService();
       essRuleConditionService.setDepStation("21618");
       essRuleConditionService.setDepStation("21872");
       essRuleConditionService.setDepStation("21381");
       essRuleConditionService.setDepStation("22379");
       essRuleConditionService.setDepStation("22605");
       essRuleConditionService.setDepStation("22131");
       essRuleConditionService.setDepStation("21915");
       return essRuleConditionService.getDepStation();
      }
      function List depStationFun68308cu() {
       EssRuleConditionService essRuleConditionService = new EssRuleConditionService();
       essRuleConditionService.setDepStation("20932");
       essRuleConditionService.setDepStation("21078");
       essRuleConditionService.setDepStation("21148");
       essRuleConditionService.setDepStation("19342");
       essRuleConditionService.setDepStation("21783");
       essRuleConditionService.setDepStation("21370");
       essRuleConditionService.setDepStation("21304");
       essRuleConditionService.setDepStation("21097");
       return essRuleConditionService.getDepStation();
      }
      function List depStationFun68309cu() {
       EssRuleConditionService essRuleConditionService = new EssRuleConditionService();
       essRuleConditionService.setDepStation("21972");
       essRuleConditionService.setDepStation("21299");
       essRuleConditionService.setDepStation("21890");
       essRuleConditionService.setDepStation("21080");
       essRuleConditionService.setDepStation("21357");
       essRuleConditionService.setDepStation("19505");
       essRuleConditionService.setDepStation("21624");
       essRuleConditionService.setDepStation("20992");
       essRuleConditionService.setDepStation("22425");
       essRuleConditionService.setDepStation("22137");
       essRuleConditionService.setDepStation("21747");
       essRuleConditionService.setDepStation("22432");
       essRuleConditionService.setDepStation("21528");
       return essRuleConditionService.getDepStation();
      }
      
      function List depStationFun68312cu() {
       EssRuleConditionService essRuleConditionService = new EssRuleConditionService();
       essRuleConditionService.setDepStation("21299");
       essRuleConditionService.setDepStation("21747");
       essRuleConditionService.setDepStation("21890");
       essRuleConditionService.setDepStation("21972");
       return essRuleConditionService.getDepStation();
      }
      rule "68307"
       dialect "java"
       when
       currentLeg : CurrentLeg()
       nextLeg : NextLeg()
       previousLeg : PreviousLeg()
       secondNextLeg : SecondNextLeg()
       secondPreviousLeg : SecondPreviousLeg()
       eval(currentLeg.getORGSTN().size()!=0 && depStationFun68307cu().containsAll(currentLeg.getORGSTN()))
       then
       currentLeg.setDataProcessedByDrool(new Boolean(true));
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68307");
       currentLeg.setEssRuleActionId("21444");
       currentLeg.setPartId("47004404");
       currentLeg.setEssAction("47004404");
       currentLeg.setFLTTYPES("47004404");
       currentLeg.setSRVSVDSVCCOD("47004404");
       currentLeg.setASSIGNSVCCODE("47004404");
       currentLeg.setASSIGNFLTTYPE("47004404");
       currentLeg.setFssBoardDailyLegId("");
       end
      rule "68308"
       dialect "java"
       when
       currentLeg : CurrentLeg()
       nextLeg : NextLeg()
       previousLeg : PreviousLeg()
       secondNextLeg : SecondNextLeg()
       eval(currentLeg.getORGSTN().size()!=0 && depStationFun68308cu().containsAll(currentLeg.getORGSTN()))
       then
       currentLeg.setDataProcessedByDrool(new Boolean(true));
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68308");
       currentLeg.setEssRuleActionId("41899");
       currentLeg.setPartId("47004405");
       currentLeg.setEssAction("47004405");
       currentLeg.setFLTTYPES("47004405");
       currentLeg.setSRVSVDSVCCOD("47004405");
       currentLeg.setASSIGNSVCCODE("47004405");
       currentLeg.setASSIGNFLTTYPE("47004405");
       currentLeg.setFssBoardDailyLegId("");
       end
      rule "68309"
       dialect "java"
       when
       currentLeg : CurrentLeg()
       nextLeg : NextLeg()
       previousLeg : PreviousLeg()
       secondNextLeg : SecondNextLeg()
       eval(currentLeg.getORGSTN().size()!=0 && depStationFun68309cu().containsAll(currentLeg.getORGSTN()))
       then
       currentLeg.setDataProcessedByDrool(new Boolean(true));
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68309");
       currentLeg.setEssRuleActionId("21446");
       currentLeg.setPartId("47004406");
       currentLeg.setEssAction("47004406");
       currentLeg.setFLTTYPES("47004406");
       currentLeg.setSRVSVDSVCCOD("47004406");
       currentLeg.setASSIGNSVCCODE("47004406");
       currentLeg.setASSIGNFLTTYPE("47004406");
       currentLeg.setFssBoardDailyLegId("");
       end
      rule "68312"
       dialect "java"
       when
       currentLeg : CurrentLeg()
       nextLeg : NextLeg()
       previousLeg : PreviousLeg()
       secondNextLeg : SecondNextLeg()
       eval(currentLeg.getORGSTN().size()!=0 && depStationFun68312cu().containsAll(currentLeg.getORGSTN()))
       then
       currentLeg.setDataProcessedByDrool(new Boolean(true));
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68312");
       currentLeg.setEssRuleActionId("72298");
       currentLeg.setPartId("47004409");
       currentLeg.setEssAction("47004409");
       currentLeg.setFLTTYPES("47004409");
       currentLeg.setSRVSVDSVCCOD("47004409");
       currentLeg.setASSIGNSVCCODE("47004409");
       currentLeg.setASSIGNFLTTYPE("47004409");
       currentLeg.setFssBoardDailyLegId("");
       currentLeg.setBRDSTN("");
       currentLeg.setCATERINGSTN("");
       currentLeg.setCLASSLIST("");
       currentLeg.setConsumptionPc("");
       currentLeg.setBoardingRatioM("");
       currentLeg.setBoardingRatioN("");
       currentLeg.setBoardingQty("");
       currentLeg.setBoardingMaxQty("");
       currentLeg.setBoardingPc("");
       if(currentLeg.getAircraftSeatCfgId()!=null) {
       if(currentLeg.getClassOfServices().contains("8091")) {
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68312");
       currentLeg.setEssRuleActionId("72292");
       currentLeg.setASSIGNSVCCODE("47004711");
       currentLeg.setEssAction("47004711");
       currentLeg.setPartId("47004711");
       currentLeg.setSRVSVDSVCCOD("47004711");
       currentLeg.setFssBoardDailyLegId("");
       currentLeg.setBRDSTN("");
       currentLeg.setCATERINGSTN("");
       currentLeg.setCLASSLIST("8091");
       currentLeg.setConsumptionPc("");
       currentLeg.setBoardingRatioM("");
       currentLeg.setBoardingRatioN("");
       currentLeg.setBoardingQty("");
       currentLeg.setBoardingMaxQty("");
       currentLeg.setBoardingPc("100");
       }
       }
       if(currentLeg.getAircraftSeatCfgId()== null) {
       currentLeg.setASSIGNSVCCODE("47004711");
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68312");
       currentLeg.setEssRuleActionId("72292");
       currentLeg.setEssAction("47004711");
       currentLeg.setPartId("47004711");
       currentLeg.setSRVSVDSVCCOD("47004711");
       currentLeg.setSRVBRDSVCCOD("47004711");
       currentLeg.setFssBoardDailyLegId("");
       currentLeg.setBRDSTN("");
       currentLeg.setCATERINGSTN("");
       currentLeg.setCLASSLIST("8091");
       currentLeg.setConsumptionPc("");
       currentLeg.setBoardingRatioM("");
       currentLeg.setBoardingRatioN("");
       currentLeg.setBoardingQty("");
       currentLeg.setBoardingMaxQty("");
       currentLeg.setBoardingPc("100");
       }
       if(currentLeg.getAircraftSeatCfgId()!=null) {
       if(currentLeg.getClassOfServices().contains("8091")) {
       currentLeg.setRuleSetId("9003");
       currentLeg.setRuleSetCategoryId("15722");
       currentLeg.setRuleGroupId("9924");
       currentLeg.setRuleId("68312");
       currentLeg.setEssRuleActionId("72293");
       currentLeg.setASSIGNSVCCODE("48005240");
       currentLeg.setEssAction("48005240");
       currentLeg.setPartId("48005240");
       currentLeg.setSRVSVDSVCCOD("48005240");
       currentLeg.setFssBoardDailyLegId("");
       currentLeg.setBRDSTN("");
       currentLeg.setCATERINGSTN("");
       currentLeg.setCLASSLIST("8091");
       currentLeg.setConsumptionPc("");
       currentLeg.setBoardingRatioM("");
       currentLeg.setBoardingRatioN("");
       currentLeg.setBoardingQty("");
       currentLeg.setBoardingMaxQty("");
       currentLeg.setBoardingPc("100");
       }
       }
       end
      



      I have the following code to access drl file :
      // get the .drl constructed as inputstream
      // droolsInputString is drl file read into String.
      // I dont have any issue reading the file but i get the null pointer exception // when the last line is executed. builder.addPackageFromDrl(source);
      
      byte[] bytesOfDRL = droolsInputString.getBytes();
      InputStream inputStream = new ByteArrayInputStream(bytesOfDRL);
      Reader source = new InputStreamReader(inputStream);
      
      PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
      
      PackageBuilder builder = new PackageBuilder(conf);
      builder.addPackageFromDrl(source);
      


      Here i get the following exception

      17:57:50,776 ERROR [STDERR] java.lang.NullPointerException
      17:57:50,776 ERROR [STDERR] at org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:54)
      17:57:50,776 ERROR [STDERR] at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
      17:57:50,776 ERROR [STDERR] at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
      17:57:50,791 ERROR [STDERR] at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
      17:57:50,791 ERROR [STDERR] at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
      17:57:50,791 ERROR [STDERR] at com.egatematrix.ess.framework.service.remote.rules.RulesEngineInvoker.readRule(RulesEngineInvoker.java:108)
      17:57:50,791 ERROR [STDERR] at com.egatematrix.ess.framework.service.RuleService.doProcess(RuleService.java:302)
      17:57:50,791 ERROR [STDERR] at com.egatematrix.ess.framework.service.FetchFSSData.invokeRuleService(FetchFSSData.java:141)
      17:57:50,791 ERROR [STDERR] at com.egatematrix.ess.framework.service.FetchFSSData.triggerData(FetchFSSData.java:69)
      17:57:50,791 ERROR [STDERR] at com.egatematrix.ess.framework.service.FetchFSSData$1.run(FetchFSSData.java:85)
      17:57:50,791 ERROR [STDERR] at java.util.TimerThread.mainLoop(Timer.java:512)
      17:57:50,791 ERROR [STDERR] at java.util.TimerThread.run(Timer.java:462)


      I have tried compiling the drl file in drl editor . there is no error.
      Can Any one Help me resolving the issue.