Solving asm conflicts after upgrading to Groovy 2.1

I’m developing a framework called REST Assured that uses Groovy as a dependency. After the recent release of REST Assured 1.8.0 the Groovy version was updated to 2.1.2. When integrating the new REST Assured release with my project at work I ran into an issue like this:

java.lang.IncompatibleClassChangeError:
   Found interface org.objectweb.asm.MethodVisitor, but class was expected
   at org.codehaus.groovy.runtime.callsite.
      CallSiteGenerator.genConstructor(CallSiteGenerator.java:141)
   at org.codehaus.groovy.runtime.callsite.
      CallSiteGenerator.genPojoMetaMethodSite(CallSiteGenerator.java:181)
   at org.codehaus.groovy.runtime.callsite.
      CallSiteGenerator.compilePojoMethod(CallSiteGenerator.java:227)
   at org.codehaus.groovy.reflection.
      CachedMethod.createPojoMetaMethodSite(CachedMethod.java:257)
   at org.codehaus.groovy.runtime.callsite.
      PojoMetaMethodSite.createCachedMethodSite(PojoMetaMethodSite.java:159)
   at org.codehaus.groovy.runtime.callsite.
      PojoMetaMethodSite.createPojoMetaMethodSite(PojoMetaMethodSite.java:148)
   at groovy.lang.MetaClassImpl.createPojoCallSite(MetaClassImpl.java:3082)
...

After a lot of investigation it turned out that the reason for this was that we used a dependency to jersey-spring which dependeded on asm version 3.1 whereas the groovy artifact required asm 4. These versions of asm are not compatible.

Solution

The solution turned out to be to exclude the groovy artifact from the build and instead depend on the groovy-all artifact. In Maven it looked like this for the REST Assured project:


    com.jayway.restassured
    rest-assured
    1.8.0
    
        
        
            org.codehaus.groovy
            groovy
        
    
    test


    org.codehaus.groovy
    groovy-all
    
    2.1.2
    test

That’s it!

This Post Has 5 Comments

  1. Thanks.

    This was the case for us too, because we were using both Swagger (ASM 3.2) and RestAssured (migration from 1.6 to 1.8)

    It did the job.

  2. thank you, this helped me a lot!

  3. Thanks a lot, This solved me too but i am curious about what is root cause of solution, i.e. what is the difference between groovy and groovy-all artifacts

  4. Thanks a lot. It was really helpful.

Leave a Reply

Close Menu