Hi list,
try to make my first experiences with Drools 6. For that purpose I've
modified slightly the 'KieFileSystemExample'
(
https://github.com/droolsjbpm/drools/blob/6.0.0.CR3/drools-examples-api/k...
)
as the code below shows. I try to use the newReaderResource(Reader reader)
but when I run maven test I get
the following error:
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.33 sec
<<< FAILURE! - in
org.drools.example.api.kiefilesystem.KieFileSystemExampleTest
testGo(org.drools.example.api.kiefilesystem.KieFileSystemExampleTest) Time
elapsed: 0.263 sec <<< ERROR!
java.lang.RuntimeException: Unable to fetch module from resource
:[ReaderResource resource=java.io.StringReader@6a5714de encoding='null']
at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106)
at
org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:192)
at
org.drools.compiler.kie.builder.impl.KieRepositoryImpl.addKieModule(KieRepositoryImpl.java:157)
at
org.drools.example.api.kiefilesystem.KieFileSystemExample.go(KieFileSystemExample.java:39)
at
org.drools.example.api.kiefilesystem.KieFileSystemExampleTest.testGo(KieFileSystemExampleTest.java:16)
public class KieFileSystemExample {
public String getRule() {
String s = "" +
"package org.drools.example.api.kiefilesystem \n\n" +
"import org.drools.example.api.kiefilesystem.Message
\n\n" +
"global java.io.PrintStream out \n\n" +
"rule \"rule 1\" when \n" +
" m : Message( ) \n" +
"then \n" +
" out.println( m.getName() + \": \" + m.getText() );
\n"
+
"end \n" +
"rule \"rule 2\" when \n" +
" Message( text == \"Hello, HAL. Do you read me, HAL?\"
) \n" +
"then \n" +
" insert( new Message(\"HAL\", \"Dave. I read
you.\" )
); \n" +
"end";
return s;
}
public void go(PrintStream out) {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieModule kModule =
kr.addKieModule(ks.getResources().newReaderResource( (Reader) new
StringReader(getRule()) ));
KieContainer kContainer =
ks.newKieContainer(kModule.getReleaseId());
KieSession kSession = kContainer.newKieSession();
kSession.setGlobal("out", out);
kSession.insert(new Message("Dave", "Hello, HAL. Do you read me,
HAL?"));
kSession.fireAllRules();
}
public static void main(String[] args) {
new KieFileSystemExample().go(System.out);
}
}
Any Idea?
Thanks in advance.
Regards,
-markus