I have the problem that the DRL file is correctly loaded (i can see it at my
system out with the content).
But when it comes to this line:
kbuilder.add(ResourceFactory.newByteArrayResource(drl.getBytes()),
ResourceType.DRL);
I have tried also the :
// kbuilder.add(ResourceFactory.newInputStreamResource(finp),
ResourceType.DRL);
// kbuilder.add(ResourceFactory.newFileResource(path),
ResourceType.DRL);
but I have always the following stacktrace:
java.lang.NullPointerException
at
org.drools.compiler.PackageBuilder.preCompileAddFunction(PackageBuilder.java:1112)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:619)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at
kn.ms.monitoring.utils.DroolsUtil.createKnowledgeBase(DroolsUtil.java:65)
at
kn.ms.monitoring.utils.DroolsUtil.getStatefulKnowledgeSession(DroolsUtil.java:79)
at kn.ms.monitoring.Main.make(Main.java:32)
at kn.ms.monitorjms.wrapper(monitorjms.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:439)
at
com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:635)
at
com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:46)
at
com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:44)
at
com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:232)
at
com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:51)
at
com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:272)
at
com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:30)
at
com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:386)
at
com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:539)
at
com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:384)
at
com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:234)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:189)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:324)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:584)
at com.wm.lang.flow.FlowState.step(FlowState.java:444)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:409)
at
com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1057)
at
com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:635)
at
com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:46)
at
com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:44)
at
com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:232)
at
com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:51)
at
com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:272)
at
com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:30)
at
com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:386)
at
com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:539)
at
com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:384)
at
com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:234)
at
com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java:119)
at
com.wm.app.b2b.server.HTTPMessageHandler.process(HTTPMessageHandler.java:160)
at
com.wm.app.b2b.server.HTTPDispatch.handleRequest(HTTPDispatch.java:190)
at com.wm.app.b2b.server.Dispatch.run(Dispatch.java:359)
at com.wm.util.pool.PooledThread.run(PooledThread.java:131)
at java.lang.Thread.run(Thread.java:619)
This is the impl:
private static KnowledgeBase createKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
//
kbuilder.add(ResourceFactory.newClassPathResource("validation.drl",
ISubscriptionService.class), ResourceType.DRL );
if (kbuilder == null) {
throw new Exception("Drools :-( ");
}
File drlFile =new File("");
String path =
drlFile.getAbsolutePath()+"/packages/KN_MS_MONITOR_JMS/config/validation.drl";
drlFile = new File(path);
FileInputStream finp=new FileInputStream(drlFile);
if (ResourceFactory.newInputStreamResource(finp) == null) {
throw new Exception("Cannot load file:"+path);
}
String drl = ConfigManager.getContents(drlFile);
System.err.println(drl);
kbuilder.add(ResourceFactory.newByteArrayResource(drl.getBytes()),
ResourceType.DRL);
//
kbuilder.add(ResourceFactory.newClassPathResource("http://127.0.0.1:5552/web/KN_MS_WEBRESOURCES/validation.drl",
ISubscriptionService.class), ResourceType.DRL );
// kbuilder.add(ResourceFactory.newInputStreamResource(finp),
ResourceType.DRL);
// kbuilder.add(ResourceFactory.newFileResource(path),
ResourceType.DRL);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
System.out.println("BasicRulesTesting.createKnowledgeBase()");
return kbase;
}
--
View this message in context:
http://n3.nabble.com/java-lang-NullPointerException-at-kbuilder-add-Resou...
Sent from the Drools - User mailing list archive at
Nabble.com.