Is there any way to create a KieSession without drools-compiler?

FGreg Source

I am trying to execute this code from my project to create a default kiesession:

KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
KieSession session = kContainer.newKieSession();

However, it fails on KieServices.Factory.get(); because:

Caused by: java.lang.RuntimeException: Unable to instance KieServices
            at org.kie.api.KieServices$Factory.<clinit>(
            ... 63 more
Caused by: java.lang.ClassNotFoundException: org.drools.compiler.kie.builder.impl.KieServicesImpl
            at Method)
            at java.lang.ClassLoader.loadClass(
            at sun.misc.Launcher$AppClassLoader.loadClass(
            at java.lang.ClassLoader.loadClass(
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(
            at org.kie.api.KieServices$Factory.<clinit>(
            ... 63 more
   at sun.reflect.NativeConstructorAccessorImpl.newInstance( ~[na:1.7.0_67]
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( ~[na:1.7.0_67]
   at java.lang.reflect.Constructor.newInstance( ~[na:1.7.0_67]
   at org.springframework.beans.BeanUtils.instantiateClass( ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
   ... 57 common frames omitted

I have a pre-compiled kjar and the kie-api as dependencies to my project. Why do I also need drools-compiler? Is there another way to create a ksession that does not require me to add drools-compiler to my dependencies (seeing as my kjar is already compiled)?

Here's the dependency portion of the project trying to use the rules:

<?xml version="1.0"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">


answered 4 years ago laune #1

KieServices isn't necessarily the DRL compiler. If you look at the API of this interface you'll see that it is the entry point for instantiating all kinds of services provided by Kie.

It so happens that the implementation is packed into the jar where all "building" stuff is kept, including the DRL compiler. This doesn't mean it will actually be used.

comments powered by Disqus