Exception when running an app via Gradle (cannot find class for closure)

I am running my application with

apply plugin: 'application'

and receive an exception in thread “main” java.lang.NoClassDefFoundError: xx/xx/LogParser$_parseFile_closure1

The same application (just a groovy file) works fine with Intellij Idea, when running with Gradle 1.6 I receive an exception in the following line:

processExceptionLine(line)

The exception stack is:

12:41:35.205 [ERROR] [system.err] Exception in thread "main" java.lang.NoClassDefFoundError: xx/xx/LogParser$_parseFile_closure1
12:41:35.206 [ERROR] [system.err]
at java.lang.invoke.MethodHandle.invokeExact(MethodHandle.java)
12:41:35.207 [ERROR] [system.err]
at xx.xx.LogParser$_parseFile_closure1.doCall(LogParser.groovy:80)
12:41:35.208 [ERROR] [system.err]
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
12:41:35.208 [ERROR] [system.err]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:41:35.209 [ERROR] [system.err]
at java.lang.reflect.Method.invoke(Method.java:606)
12:41:35.209 [ERROR] [system.err]
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
12:41:35.210 [ERROR] [system.err]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
12:41:35.210 [ERROR] [system.err]
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
12:41:35.211 [ERROR] [system.err]
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
12:41:35.211 [ERROR] [system.err]
at groovy.lang.Closure.call(Closure.java:411)
12:41:35.212 [ERROR] [system.err]
at groovy.lang.Closure.call(Closure.java:427)
12:41:35.213 [ERROR] [system.err]
at org.codehaus.groovy.runtime.DefaultGroovyMethods.callClosureForLine(DefaultGroovyMethods.java:3883)
12:41:35.213 [ERROR] [system.err]
at org.codehaus.groovy.runtime.IOGroovyMethods.eachLine(IOGroovyMethods.java:463)
12:41:35.214 [ERROR] [system.err]
at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachLine(ResourceGroovyMethods.java:269)
12:41:35.214 [ERROR] [system.err]
at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachLine(ResourceGroovyMethods.java:235)
12:41:35.215 [ERROR] [system.err]
at org.codehaus.groovy.runtime.dgm$769.doMethodInvoke(Unknown Source)
12:41:35.216 [ERROR] [system.err]
at java.lang.invoke.MethodHandleImpl$GuardWithCatch.invoke_L2(MethodHandleImpl.java:1132)
12:41:35.216 [ERROR] [system.err]
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:212)
12:41:35.217 [ERROR] [system.err]
at xx.xx.LogParser.parseFile(LogParser.groovy:58)

I did gradle clean, but didn’t help. But when I turn off the indy flag in my Groovy options everything worked. When I turned it on again, also everything worked. So I am rather confused now! Just wanted to tell this case here, I will watch this behavior closely in future. In the last I didn’t have any problems with indy flag.

Update: error comes occasionally again, turned of indy now for this skript.

Ok, the reason that IntelliJ Idea worked was that I didn’t use INDY in this build. So it is a Groovy and not a Gradle bug. I will file a Groovy bug, please close this topic.

Many thanks for the follow up.