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

3

9

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?

Hundredth answered 28/6, 2015 at 11:23 Comment(2)
Looks like you have 2 versions of groovy on the classpath. Have you tried clean before building war? Or have you got groovy added elsewhere in the tomcat instance? For example in a lib folder?Elect
yes. I did clean, compile, war. I just installed tomcat. Would it help to paste my classpath here?Hundredth
M
9

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'
    }
}
Montemayor answered 21/10, 2015 at 14:42 Comment(0)
W
2

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.

Wrongdoer answered 30/4, 2018 at 21:58 Comment(0)
S
0

You need to add code classpath 'org.codehaus.groovy:groovy-all:2.4.3' to project-level build.gradle and the error will fix.

`buildscript {  
    dependencies {  
        classpath 'org.codehaus.groovy:groovy-all:2.4.3'  
    }  
 }`
Semiaquatic answered 18/4, 2019 at 10:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.