javadroolsdrools-guvnorkie

Exception in thread "main" java.lang.ExceptionInInitializerError caused by java.lang.RuntimeException: Unable to instance KieServices


I am trying to get started with Drools 6x, and in eclipse, I have created a Drools project, which creates the boilerplate code to run a simple drl.

I have the drools runtime installed via Eclipse.

I have drools libraries, drools-core-5.0.1.jar,kie-api-6.0.0.beta4.jar,kie-internal-6.0.0.beta2.jar as External jars in my project.

Yet, when I try to run the following, I get the following error:

 java.lang.ExceptionInInitializerError 
at com.sample.PetStoreExample.init(PetStoreExample.java:78)
at com.sample.PetStoreExample.main(PetStoreExample.java:67) Caused by: java.lang.RuntimeException: Unable to instance KieServices 
    at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:137) 
    ... 1 more Caused by: java.lang.ClassNotFoundException:org.drools.compiler.kie.builder.impl.KieServicesImpl  at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Unknown Source) 
    at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:165) 
    ... 1 more  

Solution

  • If you downloaded the zip of Jars from http://www.drools.org/, you're going to want to include every jar from /binaries in your project. Even the ones that seem like you won't use.

    I had this same problem too because I assumed I only needed to use a few Jars, but it turns out they all depend on classes from the other jars in that zip folder.