Drools:drlDumper.dump()给出空指针错误

时间:2016-01-20 09:17:19

标签: java drools

我是drools的新手,我正在尝试使用drools API从.xml规则文件创建.drl。以下是用于转换的代码

    Reader source = new InputStreamReader(
            DroolsTest.class.getResourceAsStream(xmlFileName));
    XmlPackageReader xmlPackageReader = new XmlPackageReader(new SemanticModules());                
    PackageDescr pkgDesc = xmlPackageReader.read(source);
    DrlDumper drlDumper = new DrlDumper();
    String drl = drlDumper.dump(pkgDesc);
    System.out.println(drl);
    return drl;

这是异常堆栈跟踪

  

[错误:空指针:pkg.namespace] [近:{... @code {....}]                ^ [Line:1,Column:1]在org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:427)     在   org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)     在org.mvel2.ast.ASTNode.optimize(ASTNode.java:159)at   org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)at   org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)at   org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)     在   org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)     在   org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113)     在org.mvel2.MVEL.executeExpression(MVEL.java:930)at   org.mvel2.templates.res.CompiledExpressionNode.eval(CompiledExpressionNode.java:45)     在org.mvel2.templates.res.TextNode.eval(TextNode.java:42)at   org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:285)     在   org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:247)     在   org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:255)     在   org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:207)     在org.drools.compiler.lang.DrlDumper.dump(DrlDumper.java:59)at   com.sample.DroolsTest.convertXmlToDrlFile(DroolsTest.java:65)at   com.sample.DroolsTest.main(DroolsTest.java:34)引起:   java.lang.NullPointerException at   org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:360)     ......还有17个

有人可以帮我摆脱这个问题。

0 个答案:

没有答案