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.
Asked
Active
Viewed 604 times
2
-
can you reproduce this in a simple app? – Esteban Aliverti Mar 27 '19 at 14:24
-
https://github.com/gitorko/project63 Add this line to the build.gradle implementation 'org.springframework.boot:spring-boot-devtools' it stops working. Remove devtools and things work again. – user2071703 Apr 03 '19 at 13:45
2 Answers
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:
- 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. - Even if I managed to get a populated
KieBase
using akmodule.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 aProduct
object, its class is no longer the same as theProduct
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