Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat: Conflicting module versions. Module [groovy-all is loaded in version 2.3.7 and you are trying to load version 2.4.3

I have a jenkins build server that builds my grails project. I recently updated to grails 2.5.0 and the groovy comiler 2.4.3

So far so good. The jenkins is building the war again.

But when I deploy the war on my tomcat I get the error:

log4j:ERROR Error initializing log4j: null
java.lang.ExceptionInInitializerError
        at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:61)
        at groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
        at org.codehaus.groovy.grails.commons.AbstractGrailsApplication.<init>(AbstractGrailsApplication.java:45)
        at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<init>(DefaultGrailsApplication.java:95)
        at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<init>(DefaultGrailsApplication.java:91)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at java.lang.Class.newInstance(Class.java:379)
        at org.codehaus.groovy.grails.plugins.log4j.web.util.Log4jConfigListener.createGrailsApplication(Log4jConfigListener.java:54)
        at org.codehaus.groovy.grails.plugins.log4j.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:42)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.7 and you are trying to load version 2.4.3
        at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule(MetaClassRegistryImpl.java:509)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:77)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf(ExtensionModuleScanner.java:71)
        at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules(ExtensionModuleScanner.java:53)
        at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:110)
        at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:71)
        at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:33)
        ... 25 more

Can somebody tell me what I have misconfigured and where to look at?

like image 652
Bernhard Avatar asked Jun 28 '15 11:06

Bernhard


2 Answers

Gradle itself depends on Groovy (on version 2.3.7 for your version of Gradle), and so does Grails (on version 2.4.3). My suggestion is to upgrade to a version of Gradle that uses a Groovy version that is close to the one pulled in by Grails. Gradle 2.8 depends on Groovy 2.4.4, so that is close enough to version 2.4.3 to rule out any API incompatibilities.

But as Gradle would still complain about even this minor version mismatch, you need to add code to your build.gradle file to explicitly resolve the version conflict:

configurations.all {
    resolutionStrategy {
        force 'org.codehaus.groovy:groovy-all:2.4.4'
    }
}
like image 191
sschuberth Avatar answered Nov 05 '22 09:11

sschuberth


The problem definitely comes about because of the version of gradle that you are using for your builds. While sschuberth's suggestion works, I found it not to be scaleable where you have multiple developers on various versions of gradle. Your build script would not be able to accommodate each and every one of them. The only way to accommodate them all was to exclude all versions:

configurations {
    all*.exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}

This way, your build script will take your dependency-managed version of groovy, rather than whatever your gradle version is using.

like image 39
Michael Coxon Avatar answered Nov 05 '22 08:11

Michael Coxon