War plugin adds to dependencies to groovy dependencies

Hi, I’ve very basic configuration:

apply plugin: "groovy"
apply plugin: "idea"
apply plugin: "jetty"
apply plugin: "war"
  version = '1.0'
  ext {
    jettyVersion = "8.1.16.v20140903"
}
  repositories {
    mavenCentral()
}
  httpPort = 8080
stopPort = 9451
stopKey = 'foo'
  dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.7'
    providedCompile "org.eclipse.jetty.aggregate:jetty-server:${jettyVersion}"
    providedCompile "org.eclipse.jetty.aggregate:jetty-servlet:${jettyVersion}"
    providedCompile "javax.servlet:javax.servlet-api:3.1.0"
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

I don’t know why in target War file I have two groovy jars:

groovy-all-2.3.3.jar groovy-all-2.3.7.jar

this is provided by plugin but I want to have only because it doesn’t work:

java.lang.ExceptionInInitializerError
 at org.codehaus.groovy.reflection.ClassInfo.isValidWeakMetaClass(ClassInfo.java:221)
 at org.codehaus.groovy.reflection.ClassInfo.getMetaClassForClass(ClassInfo.java:191)
 at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:236)
 at pl.epam.gda.SimpleGroovyServlet.$getStaticMetaClass(SimpleGroovyServlet.groovy)
 at pl.epam.gda.SimpleGroovyServlet.<init>(SimpleGroovyServlet.groovy)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
 at java.lang.Class.newInstance(Class.java:433)
 at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
 at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.3 and you are trying to load version 2.3.7
 at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule(MetaClassRegistryImpl.java:509)
 at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:78)
 at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf(ExtensionModuleScanner.java:72)
 at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules(ExtensionModuleScanner.java:54)
 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)
 ... 30 more

Could you help me?

Which version of gradle are you using? I copied your script exactly and could not reproduce the problem (ie only groovy-2.3.7 in the war).

2.1 the newest, with intelliJ Idea, or hmmmm Idea provides another version, I will check this out ith standalone Gradle 2.1

I’ve just changed to from default configuration in idea, to use Gradle distribution and it works perfectly. Seems that IDEA 13.1.5 has bug.

thanks for help!

Still something is wrong please read it:

:war UP-TO-DATE
Error for /Kiss_legacy/gservlet
java.lang.ExceptionInInitializerError
 at org.codehaus.groovy.reflection.ClassInfo.isValidWeakMetaClass(ClassInfo.java:221)
 at org.codehaus.groovy.reflection.ClassInfo.getMetaClassForClass(ClassInfo.java:191)
 at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:236)
 at pl.epam.gda.SimpleGroovyServlet.$getStaticMetaClass(SimpleGroovyServlet.groovy)
 at pl.epam.gda.SimpleGroovyServlet.<init>(SimpleGroovyServlet.groovy)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
 at java.lang.Class.newInstance(Class.java:433)
 at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
 at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.6 and you are trying to load version 2.3.7
 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)
 ... 30 more
Nested in java.lang.ExceptionInInitializerError:
groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.6 and you are trying to load version 2.3.7
 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)
 at org.codehaus.groovy.reflection.ClassInfo.isValidWeakMetaClass(ClassInfo.java:221)
 at org.codehaus.groovy.reflection.ClassInfo.getMetaClassForClass(ClassInfo.java:191)
 at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:236)
 at pl.epam.gda.SimpleGroovyServlet.$getStaticMetaClass(SimpleGroovyServlet.groovy)
 at pl.epam.gda.SimpleGroovyServlet.<init>(SimpleGroovyServlet.groovy)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
 at java.lang.Class.newInstance(Class.java:433)
 at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
 at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
14:22:13: External task execution finished 'jettyRunWar'.

I had this problem, with Gradle 2.0: Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.3 and you are trying to load version 2.3.6

After switch to Gradle 2.1 problem solved!