2

When we have spring-boot-devtools on pom.xml the drools rules dont work. There are no error but the drools rules dont get fired at all. After excluding the spring-boot-devtools the drools rule start working.

Fabio Bonfante
  • 5,128
  • 1
  • 32
  • 37
user2071703
  • 305
  • 3
  • 8

2 Answers2

2

There's a documented issue about a classloading problem while using spring-boot devtools together with drools: DROOLS-1540

As specified in spring-boot reference documentation you can add jars to the devtools "reloading" classloader as a workaround.

META-INF/spring-devtools.properties

restart.include.drools-core=/drools-core-7.0.0.Final.jar
restart.include.drools-compiler=/drools-compiler-7.0.0.Final.jar
restart.include.kie-api=/kie-api-7.0.0.Final.jar
restart.include.kie-ci=/kie-ci-7.0.0.Final.jar
restart.include.kie-internal=/kie-internal-7.0.0.Final.jar

Be careful to use YOUR exacts jar and eventually add other libraries directly referenced in your rules files.


(for moderator) flgged Drools rule does't working in Spring Boot Controller but working in Junit Test as duplicated of this question and removed the answer on that post

Fabio Bonfante
  • 5,128
  • 1
  • 32
  • 37
1

Really strange problem indeed. As far as I can tell, there are 2 issues here:

  1. Apparently, the KieFileSystem doesn't play well with org.springframework.boot.devtools.restart.classloader.RestartClassLoader. Even if I tried passing the DRL as a String, it didn't take it.
  2. Even if I managed to get a populated KieBase using a kmodule.xml file, the rules were still not firing. My guess is that the classloader at some points changes the definition of the classes, so when you insert a Product object, its class is no longer the same as the Product class that is being used by the DRL. Another possibility is that there are multiple classloaders in play. Take a look at this question and at this document.

Unfortunately, I was not able to find a way to make it work. I hope the information I've provided helps you.

Esteban Aliverti
  • 6,259
  • 2
  • 19
  • 31