Search code examples
gradlegrailsgroovymicrometer

Adding Micrometer for Prometheus library to Grails project throws NoClassDefFoundError at run time


I am having some trouble to add micrometer library to my Grails project

The environment standard Groovy on Grails with Gradle for artifact management where build creates one big war file with all dependencies included

The Library: io.micrometer:micrometer-registry-prometheus

After adding the library: (compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.3.5')

  1. The build is successful

  2. while running Unit tests in Intellij also working as expected

But when trying to run the app it fails with error NoClassDefFoundError on class PrometheusMeterRegistry

tried to reproduce in clean new empty Grails project but there working with no issues

What i already tried:

  1. check for dependency conflicts - all looks good
  2. tried different library versions
  3. compered libraries to clean working project all looks exactly the same

Any help what might be causing this issue?

Thanks


Solution

  • It was a dependency issue which was solved by grail clean command on the module following grails war command

    I wasn't familiar with the fact that Gradle clean and Grails clean are different and Gradle clean is not sufficient in my case