Re: [rest-assured] java.lang.IncompatibleClassChangeError

810 views
Skip to first unread message

Johan Haleby

unread,
Apr 12, 2013, 2:36:07 AM4/12/13
to rest-a...@googlegroups.com
Hi, 

Thanks for your comments. Are you using Maven? In that case you may have conflicting versions of asm in classpath. REST Assured depends on Groovy 2.1.2 which depends on asm 4.x which is not backward compatible with asm 3.x. I actually had the same issue myself in my current project where Groovy and jersey-spring were in conflict. In that case you can do something like this:

             <dependency>
                <groupId>com.jayway.restassured</groupId>
                <artifactId>rest-assured</artifactId>
                <version>${rest-assured.version}</version>
                <exclusions>
                    <!-- There's a classpath clash with groovy and jersey-spring in because of incompatible asm versions, let's
                           depend on groovy-all instead which fixes the problem. -->
                    <exclusion>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy</artifactId>
                    </exclusion>
                </exclusions>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <!-- Needs to be the same version that REST Assured depends on -->
                <version>2.1.2</version>
                <scope>test</scope>
            </dependency>

Please see if it works for you. I'll probably add this to an FAQ and write a blog about it if it works.

Regards,
/Johan


On Fri, Apr 12, 2013 at 8:20 AM, Markus Moldaschl <markus.m...@gmail.com> wrote:
Hi,

I attended the REST-assured talk at confess 2013 in vienna and was pretty impressed. So I gave it a try today, but got the following stacktrace where I don't have any clue of what is wrong:

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)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(CallSiteArray.java:129)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:163)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.jayway.restassured.internal.ResponseParserRegistrar.<init>(ResponseParserRegistrar.groovy:44)
at com.jayway.restassured.RestAssured.createTestSpecification(RestAssured.java:1092)
at com.jayway.restassured.RestAssured.expect(RestAssured.java:666)
at at.willhaben.iad.remote.v2.integrationtest.LocationsRemoteIT.testGetSingleLocation(LocationsRemoteIT.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

The test looks like this:

import org.junit.Test;
import static com.jayway.restassured.RestAssured.expect;
import static org.hamcrest.Matchers.*;

/**
 *
 * @author markus.moldaschl
 */
public class LocationsRemoteIT {

    @Test
    public void testGetSingleLocation() {
        expect().body("locations.id", hasItems(117225)).when().get("/restapi/v2/locations/1030");
    }
}

I use rest-assured 1.8.0 in a maven environment. The rest-assured dependency is defined before the junit dependency.

Does anybody know what is wrong?

Thx
Markus

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Markus Moldaschl

unread,
Apr 12, 2013, 3:36:47 AM4/12/13
to rest-a...@googlegroups.com
Hi Johan,

thanks for the quick response, which fixed my problem!

Yes, we use Maven and I found that the dependency com.sun.jersey:jersey-server:1.16 has a dependendy to asm 3.1. I tried to exclude that dependendy from jersey-server and use rest-assured without exclusions but then the IncompatibleClassChangeError appeared again. So I'm not exactly sure what caused the problem in my case.

However, it works now. Thx
Markus

Johan Haleby

unread,
Apr 12, 2013, 4:02:23 AM4/12/13
to rest-a...@googlegroups.com
Great! I'll try to find time to blog and write an FAQ about this.

Jeff M

unread,
Apr 12, 2013, 4:52:34 PM4/12/13
to rest-a...@googlegroups.com
Thanks for adding this to your blogging task list.  We too had the same problem about 5 or so days ago.  It wasn't Jersey in our case (I cannot remember the lib) but it resulted in the same asm conflict.

Jeff

Johan Haleby

unread,
Apr 14, 2013, 5:11:32 AM4/14/13
to rest-a...@googlegroups.com
Thanks for sharing, always nice to get feedback.


Jeremy Ross

unread,
Jun 13, 2013, 3:21:52 PM6/13/13
to rest-a...@googlegroups.com
Thank you. Glad I found this post. +1 for adding to the FAQ for others.
Reply all
Reply to author
Forward
0 new messages