I had this issue in a Java 11 codebase that was still using Groovy 2.4 - I don't know what the exact issue was (something must have changed in Groovy 2.5 because Groovy 2.4 doesn't seem to work with Java 17) but removing the trait that was throwing the exception fixed the issue for me.