Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kogito with Decision table NullPointerException #5714

Closed
zakhdar opened this issue Nov 22, 2019 · 10 comments
Closed

Kogito with Decision table NullPointerException #5714

zakhdar opened this issue Nov 22, 2019 · 10 comments
Labels
area/kogito kind/bug Something isn't working
Milestone

Comments

@zakhdar
Copy link

zakhdar commented Nov 22, 2019

Describe the bug
create a project with Kogito extension add to src/main/ressources/ a simple xls decision table you will get a NullPointerException at compile time
Caused by: java.lang.NullPointerException at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:35)

Person POJO

package org.acme.kogito.model;
public class Person {
	private String name;
	private int age;
	private boolean adult;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public boolean isAdult() {
		return adult;
	}
	public void setAdult(boolean adult) {
		this.adult = adult;
	}
	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + ", adult=" + adult + "]";
	}
}

Person Endpoint

@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/person")
public class PersonResource {
 
    @Inject
    KieRuntimeBuilder runtimeBuilder;
 
    @POST
    public Person getCredit(Person p) {
    	
        KieSession ksession = runtimeBuilder.newKieSession();
        ksession.insert(p);
        ksession.fireAllRules();
        return p;
 
    }
}

kmodule.xml (in src/main/resources/META-INF)

<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.drools.org/xsd/kmodule" />

Expected behavior
Project can compile and excecute

Actual behavior
Actual stacktrace

Listening for transport dt_socket at address: 5005
18:16:39,095 ERROR [io.qua.run.RuntimeClassLoader] URL codeSource location for path C:\Users\Zoul.AKHDAR\git\QApplicationMicroService\QApplicationMicroService\target\classes could not be created.
18:16:39,546 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final
18:16:40,778 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.kogito.deployment.KogitoAssetsProcessor#generateModel threw an exception: java.lang.NullPointerException
        at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:35)
        at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.decisionTableToPackageDescr(KnowledgeBuilderImpl.java:392)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl$ResourceToPkgDescrMapper.lambda$static$4(CompositeKnowledgeBuilderImpl.java:320)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:196)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:183)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:97)
        at org.kie.kogito.codegen.rules.IncrementalRuleCodegen.generate(IncrementalRuleCodegen.java:181)
        at org.kie.kogito.codegen.rules.IncrementalRuleCodegen.generate(IncrementalRuleCodegen.java:71)
        at org.kie.kogito.codegen.ApplicationGenerator.lambda$generateComponents$7(ApplicationGenerator.java:217)
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at org.kie.kogito.codegen.ApplicationGenerator.generateComponents(ApplicationGenerator.java:218)
        at org.kie.kogito.codegen.ApplicationGenerator.generate(ApplicationGenerator.java:203)
        at io.quarkus.kogito.deployment.KogitoAssetsProcessor.generateModel(KogitoAssetsProcessor.java:152)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:157)
        at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:177)
        at io.quarkus.dev.DevModeMain.start(DevModeMain.java:95)
        at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.kogito.deployment.KogitoAssetsProcessor#generateModel threw an exception: java.lang.NullPointerException
        at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:35)
        at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.decisionTableToPackageDescr(KnowledgeBuilderImpl.java:392)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl$ResourceToPkgDescrMapper.lambda$static$4(CompositeKnowledgeBuilderImpl.java:320)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:196)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:183)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:97)
        at org.kie.kogito.codegen.rules.IncrementalRuleCodegen.generate(IncrementalRuleCodegen.java:181)
        at org.kie.kogito.codegen.rules.IncrementalRuleCodegen.generate(IncrementalRuleCodegen.java:71)
        at org.kie.kogito.codegen.ApplicationGenerator.lambda$generateComponents$7(ApplicationGenerator.java:217)
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at org.kie.kogito.codegen.ApplicationGenerator.generateComponents(ApplicationGenerator.java:218)
        at org.kie.kogito.codegen.ApplicationGenerator.generate(ApplicationGenerator.java:203)
        at io.quarkus.kogito.deployment.KogitoAssetsProcessor.generateModel(KogitoAssetsProcessor.java:152)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)
        at io.quarkus.builder.Execution.run(Execution.java:108)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:121)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:130)
        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:111)
        ... 3 more
Caused by: java.lang.NullPointerException
        at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:35)
        at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.decisionTableToPackageDescr(KnowledgeBuilderImpl.java:392)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl$ResourceToPkgDescrMapper.lambda$static$4(CompositeKnowledgeBuilderImpl.java:320)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildResource(CompositeKnowledgeBuilderImpl.java:196)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:183)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
        at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:97)
        at org.kie.kogito.codegen.rules.IncrementalRuleCodegen.generate(IncrementalRuleCodegen.java:181)
        at org.kie.kogito.codegen.rules.IncrementalRuleCodegen.generate(IncrementalRuleCodegen.java:71)
        at org.kie.kogito.codegen.ApplicationGenerator.lambda$generateComponents$7(ApplicationGenerator.java:217)
        at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at org.kie.kogito.codegen.ApplicationGenerator.generateComponents(ApplicationGenerator.java:218)
        at org.kie.kogito.codegen.ApplicationGenerator.generate(ApplicationGenerator.java:203)
        at io.quarkus.kogito.deployment.KogitoAssetsProcessor.generateModel(KogitoAssetsProcessor.java:152)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)

18:16:40,793 INFO  [io.qua.dev.DevModeMain] Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure

To Reproduce
Steps to reproduce the behavior:

  1. create a quarkus project (quarkus version 1.0.0.CR2) and add Kogito extension
  2. Put kmodule.xml in scr/main/resources/META-INF/
  3. Put in src/main/resources an Excel decision table
  4. Try to compile with mvn compile quarkus:dev

Environment (please complete the following information):
windows 10
Quarkus version 1.0.0.CR2
Decision table in .xlsx format
rules.xlsx

@zakhdar zakhdar added the kind/bug Something isn't working label Nov 22, 2019
@gsmet
Copy link
Member

gsmet commented Nov 22, 2019

/cc @mariofusco @mswiderski

@mswiderski
Copy link
Contributor

@zakhdar could you please check if you have following dependency in you pom?

    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>drools-decisiontables</artifactId>
    </dependency>

Decision tables is an optional component and thats why not included by default

@gsmet
Copy link
Member

gsmet commented Nov 23, 2019

@mswiderski I don't know if it will solve the issue but in any case, we shouldn't have a NPE but a proper error message.

@mswiderski
Copy link
Contributor

I fully agree with that. Once we have this confirmed we will improve the error handling in this case

@didierbokaold
Copy link

After added this dependency. No NPE and project compile fine ! Kogito extension load xlsx file right and execute all conditions.

@mswiderski
Copy link
Contributor

@dboka thanks for confirming the issue. I created Kogito Jira to track and fix it with next (0.6.0) version https://issues.jboss.org/browse/KOGITO-641

I believe this can be closed

@zakhdar
Copy link
Author

zakhdar commented Nov 23, 2019

it will be also interresting to mention this dependency in quarkus documentation

@zakhdar zakhdar closed this as completed Nov 23, 2019
@gsmet gsmet reopened this Nov 23, 2019
@gsmet
Copy link
Member

gsmet commented Nov 23, 2019

That’s a good suggestion. @mswiderski could you add something to the guide? Then we can close this issue.

Thanks!

@mswiderski
Copy link
Contributor

@gsmet @zakhdar created "using decision tables" section into kogito guide #5725

@gsmet
Copy link
Member

gsmet commented Nov 24, 2019

Let's close this issue then. Thanks!

@gsmet gsmet closed this as completed Nov 24, 2019
@gsmet gsmet added this to the 1.0.0.Final milestone Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kogito kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants