You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Martin Todorov (JIRA)" <ji...@apache.org> on 2016/06/05 15:44:59 UTC

[jira] [Commented] (MINVOKER-182) Different groovy versions on test classpath can cause ClassCastException

    [ https://issues.apache.org/jira/browse/MINVOKER-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15315921#comment-15315921 ] 

Martin Todorov commented on MINVOKER-182:
-----------------------------------------

I am getting this as well with:
{code}
mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /java/apache/maven-3.3.9
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: /java/jdk1.8.0_65/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.5.0-6-default", arch: "amd64", family: "unix"
{code}

Plugin configuration:
{code}
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-invoker-plugin</artifactId>
                        <version>2.0.0</version>

                        <configuration>
                            <debug>true</debug>
                            <preBuildHookScript>clean</preBuildHookScript>
                            <postBuildHookScript>verify</postBuildHookScript>
                            <settingsFile>src/it/settings.xml</settingsFile>
                            <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                            <addTestClassPath>true</addTestClassPath>
                        </configuration>

                        <executions>
                            <execution>
                                <id>invoker-integration-tests</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>

                                <phase>test</phase>
                            </execution>
                        </executions>

                        <dependencies>
                            <dependency>
                                <groupId>org.codehaus.groovy</groupId>
                                <artifactId>groovy-all</artifactId>
                                <version>2.4.6</version>
                            </dependency>
                        </dependencies>
                    </plugin>
{code}

I also have:
{code}
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.6</version>
            <scope>test</scope>
        </dependency>
{code}

And that doesn't seem to help.

Is there a way around this? I mean, this was all working fine for our project till a few days ago. There have been no changes to the said project in a long while and the code was running these integration tests just fine for a long time (we're using the {{maven-invoker-plugin}} to simulate Maven behavior against another project, so our CI was set up to invoke these test when there were changes to the other project).

> Different groovy versions on test classpath can cause ClassCastException
> ------------------------------------------------------------------------
>
>                 Key: MINVOKER-182
>                 URL: https://issues.apache.org/jira/browse/MINVOKER-182
>             Project: Maven Invoker Plugin
>          Issue Type: Bug
>    Affects Versions: 1.8
>            Reporter: Andrew Schurman
>            Priority: Minor
>
> When {{addTestClassPath}} is set and you have a different version of groovy than invoker on your classpath, you will run into {{ClassCastException}} when
> pre-/post- build hooks are run for tests. This occurs due to invoker creating groovy scripts in its version of groovy, but using a different version of groovy as the runtime (since test classpath elements are loaded first when {{addTestClassPath=true}}).
> In my specific case, I had a transitive dependency on groovy 1.7, but invoker uses groovy 2.0. Being transitive does make it harder to spot, but
> more importantly you may not have access to the dependency that depends on groovy. This could make swapping groovy versions impossible depending on the gap between versions.
> Stack trace:
> {code}
> groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class Script1. Reason: java.lang.ClassCastException: Script1 cannot be
>  cast to groovy.lang.GroovyObject
>         at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:443)
>         at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
>         at groovy.lang.GroovyShell.evaluate(GroovyShell.java:516)
>         at groovy.lang.GroovyShell.evaluate(GroovyShell.java:556)
>         at groovy.lang.GroovyShell.evaluate(GroovyShell.java:527)
>         at org.apache.maven.shared.scriptinterpreter.GroovyScriptInterpreter.evaluateScript(GroovyScriptInterpreter.java:83)
>         at org.apache.maven.shared.scriptinterpreter.ScriptRunner.executeRun(ScriptRunner.java:249)
>         at org.apache.maven.shared.scriptinterpreter.ScriptRunner.run(ScriptRunner.java:177)
>         at org.apache.maven.plugin.invoker.AbstractInvokerMojo.runBuild(AbstractInvokerMojo.java:1692)
>         at org.apache.maven.plugin.invoker.AbstractInvokerMojo.runBuild(AbstractInvokerMojo.java:1360)
>         at org.apache.maven.plugin.invoker.AbstractInvokerMojo.runBuilds(AbstractInvokerMojo.java:1210)
>         at org.apache.maven.plugin.invoker.AbstractInvokerMojo.execute(AbstractInvokerMojo.java:723)
>         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>         at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
>         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
>         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:606)
>         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by: java.lang.ClassCastException: Script1 cannot be cast to groovy.lang.GroovyObject
>         at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:421)
>         ... 32 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)