1

I'm using the "org.springframework.boot:spring-boot-devtools" dependency in my Grails application for the live reload of the application on code change. The problem is, it seems that this dependency is causing some conflict with drools.

On kieSession.setGlobal(name, value) in my code, I get the following error:

java.lang.RuntimeException: Illegal class for global. Expected [com.user.PersonAccount], found [com.user.PersonAccount]

Removing the "spring-boot-devtools" dependency fixes the issue but I need this dependency for the live reload, it's important in development.

Anyone knows why this dependency is causing this conflict? and what I can do to fix it or as a workaround?

Thanks in advance!

  • As a side note, you can get live reload in development _without_ devtools if you use IntelliJ IDEA (though it might need to be the paid / Ultimate version.) I've never used devtools because of incompatibilities and it always fails the security audits, but with IntelliJ I can still take advantage of live (or on-demand) reload when I make changes. – Roddy of the Frozen Peas Aug 16 '21 at 15:12
  • I use IntelliJ actually, the paid version. How do you activate the live reload? – Software Engineer Aug 17 '21 at 12:21

2 Answers2

1

To whoever might have the same issue in future, the issue is already reported and described before: https://issues.redhat.com/browse/DROOLS-1540 and a fix has been included in drools starting from version 7.26.0.Final (https://github.com/kiegroup/drools/commit/85c5308031a84a0ac4086c1df363bb1b4b3c6af9)

If you don't want to upgrade to the latest version of drools, there's still a workaround to fix the issue which is already mentioned on the devtools page of spring-boot (https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.devtools.restart.customizing-the-classload). I added META-INF/spring-devtools.properties with the jars that I want to include in the restart classloader (mainly the drools + kie jars) & the issue is fixed.

0

When the devtools recompile the class, the byte code no longer matches the byte code from your rules. It's not doing a very good job of warning you, but what it's trying to say is "you are trying to give me a com.user.PersonAccount instance, but it doesn't look like what I know a com.user.PersonAccount instance should look like."

Therefore if you insist on using this tool which will recompile things on the fly, you'll need to also recompile and reload the rules on the fly. Or not use spring-boot-devtools.

Roddy of the Frozen Peas
  • 14,380
  • 9
  • 49
  • 99