Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic compilation error with Spock 2.0-M1 and Groovy 3.0.0-RC2 #1067

Closed
szpak opened this issue Jan 2, 2020 · 8 comments · Fixed by #1150
Closed

Cryptic compilation error with Spock 2.0-M1 and Groovy 3.0.0-RC2 #1067

szpak opened this issue Jan 2, 2020 · 8 comments · Fixed by #1150
Assignees
Milestone

Comments

@szpak
Copy link
Member

@szpak szpak commented Jan 2, 2020

A try to Spock 2.0-M1 with Groovy 3.0.0-RC2 (manually playing with Groovy dependencies) results in very cryptic error message:

> Task :compileTestGroovy FAILED
startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at
jar:file:/.../spock-core-2.0-M1-groovy-2.5.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation
because of exception java.lang.reflect.InvocationTargetException

1 error

Having Groovy 2.4 and Spock 1.3-groovy-2.5 returns much more verbose:

> Task :compileTestGroovy FAILED
startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at
jar:file:/.../spock-core-1.3-groovy-2.5.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation
because of exception org.spockframework.util.IncompatibleGroovyVersionException:
The Spock compiler plugin cannot execute because Spock 1.3.0-groovy-2.5 is not compatible
with Groovy 2.4.3. For more information, see http://versioninfo.spockframework.org
Spock artifact: file:/.../spock-core-1.3-groovy-2.5.jar
Groovy artifact: file:/.../groovy-2.4.3.jar

1 error

It would be good to try to detect that incompatibility earlier and fail with more verbose error message for Spock 2.0 and Groovy 3.0.

Btw, as at least basic tests pass with Spock 2.0-groovy-2.5-SNAPSHOT and Groovy 3.0.0-RC2 maybe it would be good to allow to run Spock 2.0-M2 with Groovy 3.x to facilitate testing that configuration (before Spock can be built and tested with Groovy 3)?

@szpak szpak added this to the 2.0 milestone Feb 4, 2020
@eXsio
Copy link

@eXsio eXsio commented Feb 24, 2020

The same occurrs with M2 and Groovy 3.0.1:


Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/d:/m2_repo/org/spockframework/spock-core/2.0-M2-groovy-3.0/spock-core-2.0-M2-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception java.lang.reflect.InvocationTargetException

JDK12, gmavenplus-plugin:1.8.1:compileTests

it seems M2 is unusable with Groovy 3 for now

Full trace:


org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.8.1:compileTests (default) on project common: Error occurred while calling a method on a Groovy class from classpath.

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:566)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

Caused by: org.apache.maven.plugin.MojoExecutionException: Error occurred while calling a method on a Groovy class from classpath.

    at org.codehaus.gmavenplus.mojo.CompileTestsMojo.execute (CompileTestsMojo.java:80)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:566)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

Caused by: java.lang.reflect.InvocationTargetException

    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)

    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance (Constructor.java:490)

    at org.codehaus.gmavenplus.util.ReflectionUtils.invokeConstructor (ReflectionUtils.java:191)

    at org.codehaus.gmavenplus.mojo.AbstractCompileMojo.setupCompilationUnit (AbstractCompileMojo.java:291)

    at org.codehaus.gmavenplus.mojo.AbstractCompileMojo.doCompile (AbstractCompileMojo.java:263)

    at org.codehaus.gmavenplus.mojo.CompileTestsMojo.execute (CompileTestsMojo.java:76)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:566)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/d:/m2_repo/org/spockframework/spock-core/2.0-M2-groovy-3.0/spock-core-2.0-M2-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception java.lang.reflect.InvocationTargetException

 

1 error

 

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors (ErrorCollector.java:311)

    at org.codehaus.groovy.control.ErrorCollector.addError (ErrorCollector.java:108)

    at org.codehaus.groovy.transform.ASTTransformationVisitor.addPhaseOperationsForGlobalTransforms (ASTTransformationVisitor.java:333)

    at org.codehaus.groovy.transform.ASTTransformationVisitor.doAddGlobalTransforms (ASTTransformationVisitor.java:280)

    at org.codehaus.groovy.transform.ASTTransformationVisitor.addGlobalTransforms (ASTTransformationVisitor.java:204)

    at org.codehaus.groovy.transform.ASTTransformationVisitor.addPhaseOperations (ASTTransformationVisitor.java:168)

    at org.codehaus.groovy.control.CompilationUnit.addPhaseOperations (CompilationUnit.java:245)

    at org.codehaus.groovy.control.CompilationUnit.<init> (CompilationUnit.java:175)

    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)

    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance (Constructor.java:490)

    at org.codehaus.gmavenplus.util.ReflectionUtils.invokeConstructor (ReflectionUtils.java:191)

    at org.codehaus.gmavenplus.mojo.AbstractCompileMojo.setupCompilationUnit (AbstractCompileMojo.java:291)

    at org.codehaus.gmavenplus.mojo.AbstractCompileMojo.doCompile (AbstractCompileMojo.java:263)

    at org.codehaus.gmavenplus.mojo.CompileTestsMojo.execute (CompileTestsMojo.java:76)

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)

    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)

    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)

    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)

    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)

    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)

    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)

    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)

    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)

    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke (Method.java:566)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)

    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)

    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)

    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)

@leonard84
Copy link
Member

@leonard84 leonard84 commented Feb 24, 2020

@eXsio I could run spock-example with:

  • Java 11/13
  • groovy 3.0.0/3.0.1,
  • spock 2.0-M2-groovy-3.0
  • gmavenplus 1.6/1.8.1

Java 8 does not work (JVM crash), looks like a groovy problem not really spock.

@eXsio
Copy link

@eXsio eXsio commented Feb 24, 2020

Hmm thanks for quick reply. I will investigate further.

@szpak
Copy link
Member Author

@szpak szpak commented Feb 24, 2020

I suspect, you you can have some incompatible versions of Spock and Groovy.

Please check you Spock/Groovy dependencies:

mvn dependency:tree | grep spock
mvn dependency:tree | grep groovy

or if using a modern Linux distro:

mvn dependency:tree | grep -E "groovy|spock"

@Vampire
Copy link
Member

@Vampire Vampire commented Feb 25, 2020

Or

mvn dependency:tree | grep "groovy\|spock"

:-)

@hedgehog1833
Copy link

@hedgehog1833 hedgehog1833 commented Mar 14, 2020

I had the same issue as @eXsio with importing groovy-all 3.0.2 but then realized that Gradle downloaded groovy 2.5.x instead of 3. So I imported all the groovy modules separately instead of using -all and it worked fine also in combination with spock 2.0-M2-groovy-3.0

@szpak
Copy link
Member Author

@szpak szpak commented Mar 14, 2020

@hedgehog1833 FYI, the next Spock milestone will fetch transitively only groovy.jar, without any other groovy-* module.

In the meantime, as a preparation for that, as mentioned along the way of talking about another problem in my blog post, you might want to exclude all Groovy dependencies provided by Spock and add what you need from Groovy separately, e.g:

dependencies {
    testImplementation('org.spockframework:spock-core:2.0-M2-groovy-3.0') {
        exclude group: 'org.codehaus.groovy'
    }
    testImplementation('org.codehaus.groovy:groovy:3.0.2')
    testImplementation('org.codehaus.groovy:groovy-sql:3.0.2') //if needed
    ...
}

possibly with 3.0.2 extracted to some wariable.

@szpak
Copy link
Member Author

@szpak szpak commented Mar 15, 2020

I spent some time explaining the original problem and it seems to be on the Groovy side. I created an issues https://issues.apache.org/jira/browse/GROOVY-9469 and a PR to fix it: apache/groovy#1193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants