Following documentation: 6.1. The Basics I created a simple class Applicant which should be checked with drl file loaded from the class path by KieContainer.
From the doc:
"At this point it is possible to create a KieContainer that reads the files to be built, from the classpath.
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
The above code snippet compiles all the DRL files found on the classpath and put the result of this compilation, a KieModule, in the KieContainer. If there are no errors, we are now ready to create our session from the KieContainer and execute against some data:.."
The problem is that the drl (rules files) are not loaded into the project by the KieContainer, and not applied to my test object.
Test method:
first two lines are from the older version just to check that the file is actually on the class path. And it does find the rules file. The rules files is located under: src/main/resources/bla/checkLicense.drl - correctly under resources.
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("bla/checkLicense.drl"), ResourceType.DRL);
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession();
Applicant applicant = new Applicant("Mr John Smith",16);
System.out.println(applicant.toString());
assertTrue(applicant.isValid());
kSession.insert(applicant);
kSession.fireAllRules();
System.out.printf(applicant.toString());
assertFalse(applicant.isValid());
The output:
[main] INFO org.drools.compiler.kie.builder.impl.ClasspathKieProject - Found kmodule: file:/Users/<MyUserName>/Drools/target/classes/META-INF/kmodule.xml
[main] WARN org.drools.compiler.kie.builder.impl.ClasspathKieProject - Unable to find pom.properties in /Users/<MyUserName>/Drools/target/classes
[main] INFO org.drools.compiler.kie.builder.impl.ClasspathKieProject - Recursed up folders, found and used pom.xml /Users/<MyUserName>/Drools/pom.xml
[main] INFO org.drools.compiler.kie.builder.impl.KieRepositoryImpl - KieModule was added:FileKieModule[ ReleaseId=drools:drools-test:6.2.0-SNAPSHOTfile=/Users/<MyUserName>/Drools/target/classes]
[main] WARN org.drools.compiler.kie.builder.impl.AbstractKieModule - No files found for KieBase HelloWorldKB, searching folder /Users/<MyUserName>/Drools/target/classes
Applicant{name='Mr John Smith', age=16, valid=true}
Applicant{name='Mr John Smith', age=16, valid=true}
The applicant object stayed the same, while should've become invalid after rules invocation if the rule file was actually founded and loaded. The warning message does not appear for the git test projects provided by drools community...
My pom uses the same remote jboss remote repo and 6.2.0 SNAPSHOT dependencies...
What am I missing?
(since I am loosing my hair here, the additional +50/+100 will be awarded to the saviour, post answer acceptance)
(ignore HelloWorld in the picture)

bla/in the classpath or move ` checkLicense.drl` to one of the dirs in the class path? Either one would immediately show whether my surmise is correct. - laune