2

I am using kie-api 7.6.0.

When I am trying to get kieservices.factory.get() , its returning null.

My Java project is a gradle project.

What can be the cause? My Java project is a gradle project.

final ReleaseIdImpl releaseId = new ReleaseIdImpl(RULE_PACKAGE, RULE_NAME,
            RULE_VERSION);
    final KieServices ks = KieServices.Factory.get();

    final KieContainer kContainer = ks.newKieContainer(releaseId);

I am getting ks as null and thus NullPointerException at ks.newKieContainer(releaseId);

I have added dependencies for the following jars

drools-compiler-6.5.0.Final.jar
drools-core-6.5.0.Final.jar
drools-decisiontables-6.5.0.Final.jar
drools-jsr94-6.5.0.Final.jar
drools-persistence-jpa-6.5.0.Final.jar
drools-templates-6.5.0.Final.jar
org.drools.eclipse-6.5.0.Final.jar
kie-maven-plugin-6.5.0.Final.jar
kie-api-6.5.0.Final.jar
kie-ci-6.5.0.Final.jar
kie-internal-6.5.0.Final.jar
Soniya Abaraham
  • 85
  • 2
  • 11

2 Answers2

1

I believe it's the same cause as here: Drools 7.4.1 kieservices.factory.get() returns null

Here is my answer.


We had the same issue when trying to use Drools in our webserver with embedded Grizzly http server.

We also needed to add the drools-compiler dependency, but that alone does not fix it.

Because there are multiple kie.conf files on the class path from the different dependencies, the uber-jar ends up having just one, and then definitions for classes to load are missing.

Besides these entries from the drools-core kie.conf:

org.kie.api.io.KieResources = org.drools.core.io.impl.ResourceFactoryServiceImpl
org.kie.api.marshalling.KieMarshallers = org.drools.core.marshalling.impl.MarshallerProviderImpl
org.kie.api.concurrent.KieExecutors = org.drools.core.concurrent.ExecutorProviderImpl

we added these lines from drools-compiler to our uber-jar kie.conf:

org.kie.api.KieServices = org.drools.compiler.kie.builder.impl.KieServicesImpl
org.kie.internal.builder.KnowledgeBuilderFactoryService = org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl

Otherwise the KieServices were not loaded and KieServices.Factory.get() returned null.

We are modifying the built jar afterwards using

jar uf myjar.jar META-INF/kie.conf

to modify the contained kie.conf file. We couldn't find a clean integrated solution with Maven. Any suggestions welcome...

nicole.torres
  • 307
  • 2
  • 6
0

You're missing to add the drools-compiler, drools-core dependency in pom.xml

Yousra ADDALI
  • 332
  • 1
  • 3
  • 14