Matt,

Try these notes - they are ONLY my notes, not a step by step on how to do it but it should give you some inspiration on how to tackle the issue. If it's still a problem, let me know and I'll do a step by step for you from scratch.

-matt

Drools Examples Porting Project Notes:


Notes:
This project is to take the stock V6 Drools examples and port them over to MyDroolsExamples Project for inclusion in my GitHub Repository.
This assumes you are using Eclipse with the Maven and Drools 6.x plugins installed, and you are at the point where you can run a Drools 6X hello world example app.

First - Create an stock Drools V6 Project w/Hello World Example, add in the external JAR: slf4j-jdk14-1.7.5.jar (http://www.slf4j.org/download.html) to get the logging working correctly, test run as Java Application, and then convert to Maven project.  Drools V6 is inherently Maven so this is a critical step, creates the important pom.xml file. 

kModule.xml <== Find this file!!!
This is the file that tells drools where to find the Rules and how to name the XML references that load them Think Injection style IoC (Spring Like) infrastructure. It can also be done programatically.  

The kmodule you need to use is located in the src/main/resources/META-INF directory

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
    <kbase name="rules" packages="rules">
        <ksession name="ksession-rules"/>
    </kbase>
</kmodule>



First Port
org.drools.examples.fibonacci

1. Clone the Packages for the Java and the Rules, copy over the Java Class and the DRL file in their respective places, and ammend the kmodule.xml file to be:

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
    <kbase name="rules" packages="rules">
        <ksession name="ksession-rules"/>
    </kbase>
    <kbase name="org.drools.examples.fibonacci" packages="org.drools.examples.fibonacci">
        <ksession name="FibonacciKS"/>
    </kbase>
</kmodule>



Adding the KIE plugin to a Maven pom.xml -> A Source of problems

THIS:
      <plugin>
        <groupId>org.kie</groupId>
        <artifactId>kie-maven-plugin</artifactId>
        <version>${project.version}</version>
        <extensions>true</extensions>
      </plugin>

BECOMES THIS:
      <plugin>
        <groupId>org.kie</groupId>
        <artifactId>kie-maven-plugin</artifactId>
        <version>6.0.1.Final</version>
        <extensions>true</extensions>
      </plugin>  

AFTER LOOKING HERE:
http://mvnrepository.com/artifact/org.kie/kie-maven-plugin/6.0.1.Final
... and changing this: 6.0.1.Final

***> and then doing a Maven: Update Project execution
This is an important step to do often if you get wierd errors since it forces a refresh to the project.



Running the Java class gives me this:
SEVERE: Unknown KieSession name: FibonacciKS
Exception in thread "main" java.lang.NullPointerException
at org.drools.examples.fibonacci.FibonacciExample.main(FibonacciExample.java:31)

Therefore the kmodule.xml is incorrect ....

Researching Here: 
http://stackoverflow.com/questions/20315910/getting-null-pointer-exception-while-running-helloworld-in-drools
http://stackoverflow.com/questions/21466716/unknown-kiesession-name-in-drools-6-0-while-trying-to-add-drools-to-existing-ma


This doc talks about the various ways a KBase can be built, and there are many ....
http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/KIEChapter.html#KIEExamplesSection


This is the code base for the examples....
https://github.com/droolsjbpm/drools/tree/master/drools-examples-api




SOLUTION:

This kmodule.xml is found under src/main/resources/META-INF/kmodule.xml
... once I added the highlighted XML extry it worked like a charm. The "kbase name" is the location of the RULES DRL,
the "ksession name" is the Java Class location. 

So in this case it would be: 


kbase name="org.drools.examples.fibonacci" src/main/resources/org.drools.examples.fibonacci
ksession name="FibonacciKS" src/main/java/org.drools.examples.fibonacci



<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
    <kbase name="rules" packages="rules">
        <ksession name="ksession-rules"/>
    </kbase>
    <kbase name="org.drools.examples.fibonacci" packages="org.drools.examples.fibonacci">
        <ksession name="FibonacciKS"/>
    </kbase> 
    <kbase name="org.drools.examples.backwardchaining" packages="org.drools.examples.backwardchaining">
        <ksession name="HouseOfDoomKS"/>
    </kbase> 
    <kbase name="org.drools.examples.honestpolitician" packages="org.drools.examples.honestpolitician">
        <ksession name="HonestPoliticianKS"/>
    </kbase>  
    <kbase name="org.drools.examples.golfing" packages="org.drools.examples.golfing">
        <ksession name="GolfingKS"/>
    </kbase>  
    <kbase name="org.drools.examples.shopping" packages="org.drools.examples.shopping">
        <ksession name="ShoppingKS"/>
    </kbase>   
    <kbase name="StateSalienceKB" packages="org.drools.examples.state.salience">
        <ksession name="StateSalienceKS"/>
    </kbase>
    <kbase name="StateAgendaGroupKB" packages="org.drools.examples.state.agendagroup">
        <ksession name="StateAgendaGroupKS"/>
    </kbase>   
    <kbase name="org.drools.examples.cashflow" packages="org.drools.examples.cashflow">
        <ksession name="CashFlowKS"/>
    </kbase>  
</kmodule>


On Tue, Feb 25, 2014 at 12:30 PM, mattmadhavan <mmadhavan@facs.org> wrote:
HI Matt,
I have downloaded your examples and want to try them out. But I having
building -ANY- 6.x examples - not just your examples. Maven is not able to
resolve any 6.x repositories.

Any ideas please? When I tired to build your examples I am getting the
following errors.



Please note that I have no problem with drools 5.x aritfacts.

Any idea please?

Thanks in advance!

Matt'M




--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-x-Stand-alone-Examples-tp4028219p4028313.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
#########################################################
Matthew R. Versaggi, President & CEO
Versaggi Information Systems, Inc.
Adjunct Professor of eBusiness DePaul University
Email: mailto:matt@versaggi.com, ProfVersaggi@gmail.com
M: 630-292-8422 
LinkedIn:  http://www.linkedin.com/in/versaggi
#########################################################