Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solve Error java.lang.NoSuchMethodError: org.codehaus.groovy.ast.ModuleNode.getStarImports()Ljava/util/List;

Tags:

java

groovy

I am encountering this exception.

Exception :java.lang.NoSuchMethodError: org.codehaus.groovy.ast.ModuleNode.getStarImports()Ljava/util/List;

I have tried various version of groovy jars like groovy 1.8.4, groovy 1.8.6 etc. But I am not able to get rid of this error.

like image 650
Dhruv Bansal Avatar asked Feb 10 '12 06:02

Dhruv Bansal


2 Answers

This happened to me when I had 2 different versions of Groovy in the classpath at the same time. Check your classpath especially if using something that obfuscates it such as Eclipse or Maven.

In my specific case, I was trying to use Groovy 1.8.6 but a Maven dependency was dragging in 1.6.5 causing errors. It worked fine running unit tests on the command line, but not from within Eclipse.

like image 86
Mike Miller Avatar answered Nov 11 '22 13:11

Mike Miller


To compile with Groovy 2.x, try adding this to the gmaven plugin element:

<configuration>
    <providerSelection>2.0</providerSelection>
    <source>2.0</source>
</configuration>

For example:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <providerSelection>2.0</providerSelection>
                <source>2.0</source>
            </configuration>
        </plugin>
    </plugins>
</build>

with

<dependencies>  
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.1.9</version>
    </dependency>
</dependencies>

seems to work.

like image 8
Michael Bosworth Avatar answered Nov 11 '22 14:11

Michael Bosworth