{"record":{"id":"7bf599edd92cb7eb","repo":"pentaho/pentaho-kettle","slug":"rulesdata-error-compiledrl","errorCode":"RulesData.Error.CompileDRL","errorMessage":"RulesData.Error.CompileDRL","messagePattern":"RulesData\\.Error\\.CompileDRL","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"plugins/drools/core/src/main/java/org/pentaho/di/trans/steps/rules/RulesAccumulatorData.java","lineNumber":98,"sourceCode":"\n  public void initializeRules() {\n\n    // To ensure the plugin classloader use for dependency resolution\n    ClassLoader orig = Thread.currentThread().getContextClassLoader();\n    ClassLoader loader = getClass().getClassLoader();\n    Thread.currentThread().setContextClassLoader( loader );\n    KieServices kieServices = KieServices.Factory.get();\n    KieFileSystem kfs = kieServices.newKieFileSystem();\n    String internalFilePath = \"src/main/resources/kettle.drl\";\n\n    if ( ruleString != null ) {\n      kfs.write( internalFilePath, ruleString );\n    } else {\n      try {\n        FileInputStream fis = new FileInputStream( ruleFilePath );\n        kfs.write( internalFilePath, kieServices.getResources().newInputStreamResource( fis ) );\n      } catch ( FileNotFoundException e ) {\n        throw new RuntimeException( BaseMessages.getString( PKG, \"RulesData.Error.CompileDRL\" ) );\n      }\n    }\n    KieBuilder kieBuilder = kieServices.newKieBuilder( kfs ).buildAll();\n    Results results = kieBuilder.getResults();\n\n    if ( results.hasMessages( Message.Level.ERROR ) ) {\n      System.out.println( results.getMessages() );\n      throw new RuntimeException( BaseMessages.getString( PKG, \"RulesData.Error.CompileDRL\" ) );\n    }\n\n    KieContainer kieContainer = kieServices.newKieContainer( kieServices.getRepository().getDefaultReleaseId() );\n    kieBase = kieContainer.getKieBase();\n\n    // reset classloader back to original\n    Thread.currentThread().setContextClassLoader( orig );\n  }\n\n  public void initializeInput( RowMetaInterface _inputRowMeta ) {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/drools/core/src/main/java/org/pentaho/di/trans/steps/rules/RulesAccumulatorData.java#L80-L116","documentation":"RulesAccumulatorData.initializeRules compiles the DRL rule string for the Drools step. If a rule file path is configured but the file does not exist, the FileInputStream constructor throws FileNotFoundException, which is rethrown as a RuntimeException with RulesData.Error.CompileDRL, aborting rule initialization.","triggerScenarios":"The step is configured to load rules from a file whose path does not exist (or is not readable) at execution time, so new FileInputStream(ruleFilePath) throws FileNotFoundException.","commonSituations":"Moving transformations between environments where the absolute rule file path differs; rule file deleted or renamed; wrong working directory for a relative path; missing mount on a cluster node.","solutions":["Correct the rule file path in the step dialog or use an absolute path valid on the executing node","Embed the rules as a string in the step instead of referencing a file","Verify the file exists and is readable at runtime on every execution node"],"exampleFix":"// before\nString ruleFilePath = \"/opt/rules/old_name.drl\"; // missing\n// after\nString ruleFilePath = \"/opt/rules/accumulate_rules.drl\"; // existing file\nnew java.io.File(ruleFilePath).exists(); // verify before run","handlingStrategy":"validation","validationCode":"File f = new File(ruleFilePath);\nif (!f.isFile() || !f.canRead()) throw new IllegalArgumentException(\"Rule file missing/unreadable: \" + ruleFilePath);","typeGuard":null,"tryCatchPattern":"try { data.initializeRules(...); } catch (RuntimeException e) { if (e.getMessage().contains(\"CompileDRL\")) { logError(\"Check the rule file path\"); } }","preventionTips":["Use environment-relative or embedded rules instead of absolute paths","Verify rule file existence on every cluster node at startup","Check the DRL compiles (KieBuilder results) after edits"],"tags":["kettle","drools","drl","file-io"],"backgroundTag":"file-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}