Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-57

NPE when creating Kie container with a guided decision table and not having drools-workbench-models-guided-dtable on classpath

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 7.4.0.GA
    • 7.0.0
    • BRE
    • None
    • 1
    • ER2
    • CR1
    • 2019 Week 17-19

      KieServices kieServices = KieServices.Factory.get();
      ReleaseId rid = kieServices.newReleaseId("optacloud", "optacloud", "1.0.0-SNAPSHOT");
      KieContainer kieContainer = kieServices.newKieContainer(rid);
      

      The optacloud project was built in Business Central. The code above is part of a test in a Maven project. The code creates a Kie container by consuming the resulting JAR from local Maven repo. If the project contains a guided decision table then the code above causes a NullPointerException unless drools-workbench-models-guided-dtable is on classpath (by adding a dependency in POM).

      The problem is that the NPE doesn't help with identifying the cause. The request of this ticket is to improve the failure message to clearly identify the file which caused the error (as soon as possible aka fail fast) and suggest a solution if possible. This is commonly practiced in optaplanner by appending a "Maybe" clause to the exception message. In this case it could look like:

      ModelNotFoundException: The file 'my decision table.gdst' was recognized
      as a Guided Decision Table but the model classes needed to build kbase
      from are not present on classpath.
      Maybe add org.drools:drools-workbench-models to your project dependencies.
      

      The NPE stack trace:

      java.lang.NullPointerException: null
      	at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.guidedDecisionTableToPackageDescr(KnowledgeBuilderImpl.java:408)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl$14.map(CompositeKnowledgeBuilderImpl.java:460)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:333)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:322)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:115)
      	at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
      	at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:232)
      	at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:74)
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:251)
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieModule(KieBuilderImpl.java:243)
      	at org.kie.scanner.KieRepositoryScannerImpl.build(KieRepositoryScannerImpl.java:248)
      	at org.kie.scanner.KieRepositoryScannerImpl.buildArtifact(KieRepositoryScannerImpl.java:198)
      	at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:154)
      	at org.kie.scanner.KieRepositoryScannerImpl.loadArtifact(KieRepositoryScannerImpl.java:149)
      	at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.loadKieModuleFromMavenRepo(KieRepositoryImpl.java:192)
      	at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:138)
      	at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:115)
      	at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:184)
      	at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172)
      	at org.jboss.qa.brms.authoring.planner.OptacloudTest.validateOptacloud(OptacloudTest.java:78)
      
      

              mfusco@redhat.com Mario Fusco
              jlocker Jiří Locker (Inactive)
              Tibor Zimányi Tibor Zimányi
              Tibor Zimányi Tibor Zimányi
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: