I am working on drools implementation in android, stuck in an issue
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.decurtis.drooldemo/com.decurtis.drooldemo.MainActivity}: java.lang.RuntimeException: Unable to instantiate object for class 'org.drools.android.DexPackageClassLoader' with constructor public org.drools.android.DexPackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData,java.lang.ClassLoader)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.RuntimeException: Unable to instantiate object for class 'org.drools.android.DexPackageClassLoader' with constructor public org.drools.android.DexPackageClassLoader(org.drools.core.rule.JavaDialectRuntimeData,java.lang.ClassLoader)
at org.drools.core.util.ClassUtils.instantiateObject(ClassUtils.java:272)
at org.drools.core.rule.JavaDialectRuntimeData.makeClassLoader(JavaDialectRuntimeData.java:618)
at org.drools.core.rule.JavaDialectRuntimeData.onAdd(JavaDialectRuntimeData.java:243)
at org.drools.compiler.rule.builder.dialect.java.JavaDialect.(JavaDialect.java:187)
at org.drools.compiler.rule.builder.dialect.java.JavaDialectConfiguration.newDialect(JavaDialectConfiguration.java:91)
at org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl.buildDialectRegistry(KnowledgeBuilderConfigurationImpl.java:392)
at org.drools.compiler.compiler.PackageRegistry.(PackageRegistry.java:55)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.newPackage(KnowledgeBuilderImpl.java:1571)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.initPackageRegistry(KnowledgeBuilderImpl.java:1044)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.createPackageRegistry(KnowledgeBuilderImpl.java:1015)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.initPackageRegistries(CompositeKnowledgeBuilderImpl.java:297)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:116)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:244)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:64)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:230)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:198)
at com.decurtis.drooldemo.MainActivity.kieExecute63(MainActivity.java:81)
at com.decurtis.drooldemo.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at org.drools.core.util.ClassUtils.instantiateObject(ClassUtils.java:270)
at org.drools.core.rule.JavaDialectRuntimeData.makeClassLoader(JavaDialectRuntimeData.java:618)
at org.drools.core.rule.JavaDialectRuntimeData.onAdd(JavaDialectRuntimeData.java:243)
at org.drools.compiler.rule.builder.dialect.java.JavaDialect.(JavaDialect.java:187)
at org.drools.compiler.rule.builder.dialect.java.JavaDialectConfiguration.newDialect(JavaDialectConfiguration.java:91)
at org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl.buildDialectRegistry(KnowledgeBuilderConfigurationImpl.java:392)
at org.drools.compiler.compiler.PackageRegistry.(PackageRegistry.java:55)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.newPackage(KnowledgeBuilderImpl.java:1571)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.initPackageRegistry(KnowledgeBuilderImpl.java:1044)
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.createPackageRegistry(KnowledgeBuilderImpl.java:1015)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.initPackageRegistries(CompositeKnowledgeBuilderImpl.java:297)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackages(CompositeKnowledgeBuilderImpl.java:116)
at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:105)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.buildKnowledgePackages(AbstractKieModule.java:244)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:64)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:230)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:198)
at com.decurtis.drooldemo.MainActivity.kieExecute63(MainActivity.java:81)
at com.decurtis.drooldemo.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
at org.drools.android.MultiDexClassLoader.(MultiDexClassLoader.java:70)
07-27 04:43:48.294 16631-16631/com.decurtis.drooldemo E/AndroidRuntime: at org.drools.android.DexPackageClassLoader.(DexPackageClassLoader.java:44)
Code : I am using drools 6.5.0 version and getting above error.
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write(ResourceFactory.newClassPathResource("rules/Fire.drl", Fire.class));
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll(); // kieModule is automatically deployed to KieRepository if successfully built.
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
KieSession kSession = kContainer.newKieSession();
System.out.println("Fire All Rules...");
kSession.fireAllRules();
kSession.dispose();
Have anyone experience this error, plz help me in out?
No comments:
Post a Comment