Google Groups

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


Markus Moldaschl Apr 12, 2013 12:36 AM
Posted in group: REST assured
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




Am Freitag, 12. April 2013 08:36:07 UTC+2 schrieb Johan Haleby:
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.