I've managed to run Drools with CDI using version 6.3.0.Final, CDI version 1.2 and Weld version 2.30.Final. Using code sample below.
https://github.com/Salaboy/drools-workshop/tree/master/my-first-drools-project
public class App {
@Inject
@KSession
private KieSession kSession;
public void bootstrapDrools() {
// The KieSession was injected so we can use it now
kSession.insert("Hi There!");
int rulesFired = kSession.fireAllRules();
System.out.println(">>> Rules Fired: "+rulesFired);
}
public static void main(String[] args) {
//Boostrap the CDI container, in this case WELD
Weld w = new Weld();
WeldContainer wc = w.initialize();
App app = wc.select(App.class).get();
app.bootstrapDrools();
w.shutdown();
}
}
Now I'm trying to do the same using drools 7.2.0 final.
But I can't get it to work. Any ideas?
As I answer in my blog post you need to add the following dependency in drools 7 to get those examples working: org.drools drools-cdi ${kie.version}