[rules-users] java.lang.RuntimeException: Unable to instance KieServices

Mark Proctor mproctor at codehaus.org
Thu Jan 9 09:39:10 EST 2014


You are missing required dependencies. All the api bootstrapping examples are documented and can be found here:
https://github.com/droolsjbpm/drools/tree/master/drools-examples-api

either use "mvn eclipse:eclipse” or the m2e plugin, and you will will be good to go.

Mark
On 9 Jan 2014, at 10:57, kurrent93 <kurrent93 at gmail.com> wrote:

> Hi
> 
> 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.
> 
> Yet, when I try to run the following, I get  the following error:
> 
> java.lang.ExceptionInInitializerError
> 	at com.sample.DroolsTest.main(DroolsTest.java:15)
> Caused by: java.lang.RuntimeException: Unable to instance KieServices
> 	at org.kie.api.KieServices$Factory.<clinit>(KieServices.java:167)
> 	... 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
> 
> 
> 
> package com.sample;
> 
> import org.kie.api.KieServices;
> import org.kie.api.runtime.KieContainer;
> import org.kie.api.runtime.KieSession;
> 
> /**
> * This is a sample class to launch a rule.
> */
> public class DroolsTest {
> 
>    public static final void main(String[] args) {
>        try {
>            // load up the knowledge base
> 	        KieServices ks = KieServices.Factory.get();
>    	    KieContainer kContainer = ks.getKieClasspathContainer();
>        	KieSession kSession = kContainer.newKieSession("ksession-rules");
> 
>            // go !
>            Message message = new Message();
>            message.setMessage("Hello World");
>            message.setStatus(Message.HELLO);
>            kSession.insert(message);
>            kSession.fireAllRules();
>        } catch (Throwable t) {
>            t.printStackTrace();
>        }
>    }
> 
>    public static class Message {
> 
>        public static final int HELLO = 0;
>        public static final int GOODBYE = 1;
> 
>        private String message;
> 
>        private int status;
> 
>        public String getMessage() {
>            return this.message;
>        }
> 
>        public void setMessage(String message) {
>            this.message = message;
>        }
> 
>        public int getStatus() {
>            return this.status;
>        }
> 
>        public void setStatus(int status) {
>            this.status = status;
>        }
> 
>    }
> 
> }
> 
> 
> 
> 
> --
> View this message in context: http://drools.46999.n3.nabble.com/java-lang-RuntimeException-Unable-to-instance-KieServices-tp4027622.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list