问题
This is my first time using Drools and am looking to integrate it with a pre-existing eclipse project. I am using the Drools eclipse plugin. I can successfully create a Drools project and run it without error. However, when I try and use Drools in a normal Java project (the project that existed before I had installed the Drools plugin) I receive a NullPointerException and debugging shows that my KieSession is null:
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("ksession-rules");
//kSession is null
I have tried to recreate the directories as best as I can (a resources folder and a main folder) and have modified the package names where I can. I suspect that something has gone wrong with creating the directories and files and they cant be found when the KieSession is initialized.
Unfortunately all I can find are related to creating a new Drools project, nothing to do with adding Drools to an existing project. What steps do I need to take to do this? Is there a way I can automatically add the files/packages/directories needed without effecting my current project?
来源:https://stackoverflow.com/questions/39743210/integrating-drools-with-a-pre-existing-eclipse-project