I am trying to integrate Drool with
ofbiz and run application from command prompt. In one way I have integrated
it properly and I am able to run it successfully.
Code : Which I was using initially KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); or PackageBuilderConfiguration cfg = new PackageBuilderConfiguration(); KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); Exception I got : org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java :org.drools.rule.builder.dialect.java.JavaDialectConfiguration' at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274) at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259) at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176) at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153) at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242) . . . Caused by: java.lang.NullPointerException at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:92) at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55) at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270 Problem I found : In the class JavaDialectConfiguration in jar file drools-compiler.jar there is a method named "setCompliler", in this method Null Pointer Exception was coming. Solution I provided : In my application I created my custom class CustomJavaDialectConfiguration by extending to class JavaDialectConfiguration, In this class I overrided the method setCompiler. My method was exactly same as that of method setCompiler in JavaDialectConfiguration . To call my dialect class I also overrided the method "addDialect" of PackageBuilderConfiguration class . For that I created class CustomPackageBuilderConfiguration by extending to PackageBuilderConfiguration. after that I wrote the code: PackageBuilderConfiguration cfg = new CustomPackageBuilderConfiguration(); KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(cfg); Now application is running perfectly fine from both eclipse and command prompt without any exception. I want to know as my overrided method "setCompiler" was exactly same then why I had to override method, and In original code (ie in drools-compiler.jar file) why it was giving exception ??? Was that due to class lader or something else ?? Please do help in this regard .... |