[rules-users] Drools 601 kmodule problem when running the drools project in eclipse kepler ide
Natalia Iglesias de Amunategui
natalia.iglesias at casadearriba.net
Sun May 25 10:29:23 EDT 2014
Hello,
I had already tried something like that by changing the packages field in
the kmodule file into packages=rules as this is the directory where the
VAP.drl file resides. But I still get a null pointer exception when
executing the container verify, although I do not see a warning anymore:
The error comes from the line 36 (container verify):
System.out.println(kContainer.verify().getMessages().toString());
I am running out of ideas, I also thought that it maybe has something to do
with maven as I have read that drools 601 expects a maven structure, so I
definitely needs a pom.properties. I have a pom.properties but is has no
content, only this:
version=${project.version}
groupId=${project.groupId}
artifactId=${project.artifactId}
Thanks!
De: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] En nombre de Mauricio Salatino
Enviado el: domingo, 25 de mayo de 2014 16:18
Para: Rules Users List
Asunto: Re: [rules-users] Drools 601 kmodule problem when running the drools
project in eclipse kepler ide
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 at 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=\T
FM\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=\T
FM\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 Im 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"
xmlns="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 Im 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 at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
- MyJourney @ http://salaboy.com <http://salaboy.wordpress.com>
- Co-Founder @ http://www.jugargentina.org
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
---
Este mensaje no contiene virus ni malware porque la protección de avast! Antivirus está activa.
http://www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140525/46b4c8ab/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 56322 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20140525/46b4c8ab/attachment-0001.jpe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1833 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20140525/46b4c8ab/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 10458 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20140525/46b4c8ab/attachment-0003.png
More information about the rules-users
mailing list