Try creating a directory called: *InfectionRules inside the
src/main/resources/*
*and then put the rules inside there.*
On Sun, May 25, 2014 at 3:04 PM, Natalia Iglesias de Amunategui <
natalia.iglesias(a)casadearriba.net> wrote:
Hello,
I am currently working on a Drools project using eclipse kepler and the
drools plug-in from drools 601.
I have a main java class that contains POJO classes representing facts and
the initialization of the kie container and session. When executing the
command System.*out*
.println(kContainer.verify().getMessages().toString()); I get the
following messages:(note the warning “No files found for KieBase
InfectionRules, searching folder…”)
[main] INFO org.drools.compiler.kie.builder.impl.ClasspathKieProject -
Found kmodule:
file:/C:/TFM/Infections/Workspace/InfectionRules/VAP/target/META-INF/kmodule.xml
[main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl -
KieModule was added:FileKieModule[
ReleaseId=${project.groupId}:${project.artifactId}:${project.version}file=\TFM\Infections\Workspace\InfectionRules\VAP\target]
[main] INFO org.drools.compiler.kie.builder.impl.ClasspathKieProject -
Found kmodule:
file:/C:/TFM/Infections/Workspace/InfectionRules/VAP/target/META-INF/kmodule.xml
[main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl -
KieModule was added:FileKieModule[
ReleaseId=${project.groupId}:${project.artifactId}:${project.version}file=\TFM\Infections\Workspace\InfectionRules\VAP\target]
[main] WARN org.drools.compiler.kie.builder.impl.AbstractKieModule - *No
files found for KieBase InfectionRules, searching folder
\TFM\Infections\Workspace\InfectionRules\VAP\target*
[]
*java.lang.NullPointerException*
at InfectionRules.VAPDroolsTest.main(*VAPDroolsTest.java:62*)
The kie initialization module has the following code:
*package* InfectionRules;
*import* java.util.*;
*import* java.util.concurrent.TimeUnit;
*import* java.text.DateFormat;
*import* java.text.SimpleDateFormat;
*import* org.drools.core.time.*;
*import* *org.kie.internal*.*;
*import* org.kie.api.conf.EventProcessingOption;
*import* *org.kie.api.runtime.KieRuntime*;
*import* org.kie.api.KieBaseConfiguration;
*import* org.kie.api.KieServices;
*import* org.kie.api.runtime.KieContainer;
*import* org.kie.api.runtime.KieSession;
*import* org.kie.api.runtime.KieSessionConfiguration;
*import* org.kie.api.runtime.conf.ClockTypeOption;
*import* org.kie.api.runtime.rule.EntryPoint;
*import* org.kie.api.runtime.rule.FactHandle;
*import* *org.kie.api.time.SessionClock*;
*public* *static* *void* main(*final* String[] args) {
*try* {
// load up the knowledge base
KieServices ks = KieServices.Factory.*get*();
KieContainer kContainer = ks.getKieClasspathContainer();
System.*out*
.println(kContainer.verify().getMessages().toString());
KieSession kSession = kContainer.newKieSession("VAPSession");
// set clock to pseudo clock to be able to advance it
manually
KieSessionConfiguration ksconf = KieServices.Factory.*get*
().newKieSessionConfiguration();
ksconf.setOption(ClockTypeOption.*get*("pseudo"));
*SessionPseudoClock* clock = kSession.getSessionClock();
// set stream mode as opposite to cloud mode
KieBaseConfiguration config = KieServices.Factory.*get*
().newKieBaseConfiguration();
config.setOption(EventProcessingOption.*STREAM* );
// Insert test patients and related classes
// *mr* *Jones* has no VAP, so the *cpi* score is less than 6
*final* Patient p1 = *new* Patient( "MrJones", 45, 1, *false*
,*false*,*true*,37.0,
5000,"None","No Infiltrate","None","No
Growth","S.Aureus"
,235,*true*, *false*, 0,
*true*,*new* SimpleDateFormat("yyyy-MM-dd").parse(
"2014-05-17"),"",
*new*
SimpleDateFormat("yyyy-MM-dd").parse("2014-05-17"),
*false*,*false*,*false*,*false*);
kSession.insert( p1 );
// get a reference to the entry point and insert events
EntryPoint nursingStream = kSession.getEntryPoint(
"NursingStream" );
* final* CPIScore cpiScore1 = *new* CPIScore( p1,"initial",7);
nursingStream.insert( cpiScore1 );
*clock.advanceTime( 75, TimeUnit.**HOURS** )*;
*final* CPIScore cpiScore2 = *new* CPIScore( p1,"3days",7 );
nursingStream..insert( cpiScore2 );
I am running this class directly from the Eclipse Run menu option. I have
installed maven but I’m not using it (yet)
The kmodule.xml file has the following format:
<?xml version=*"1.0"* encoding=*"UTF-8"*?>
<kmodule
xmlns:xsi=*"http://www.w3.org/2001/XMLSchema-instance
<
http://www.w3.org/2001/XMLSchema-instance>"*
xmlns=*"http://jboss.org/kie/6.0.0/kmodule
<
http://jboss.org/kie/6.0.0/kmodule>"*>
<kbase name=*"InfectionRules"* eventProcessingMode=*"stream"*
packages=*"InfectionRules"*>
<ksession name=*"VAPSession"* type=*"stateful"*
clockType=
*"pseudo"* />
</kbase>
</kmodule>
(I have tried to change the packages field of kmodule to *, but it does
not work either.)
And the directory structure where both the java and drl code reside is:
C:\TFM\Infections\Workspace\InfectionRules\VAP\src\main
Subdirectory java contains the java classes and resources the drl file.
The target directory is located under ..\VAP\target\ with the following
structure:
From Eclipse IDE this is the project structure
Any idea as to what I’m doing wrong? I don´t know why the kmodule does not
locate the kbase in the directory *\TFM\Infections\Workspace\InfectionRules\VAP\target
*as this directory contains the drl file vap.drl in the rules
subdirectory. Although I get later a null pointer exception, I guess that
it has to do with this warning, as if there is no kbase located no session
can be used.
Thanks in advance!
Best regards
Natalia
------------------------------
<
http://www.avast.com/>
Este mensaje no contiene virus ni malware porque la protección de avast!
Antivirus <
http://www.avast.com/> está activa.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users