Conflicting module versions. Module [groovy-xml is loaded in version 4.x.x and you are trying to load version 3.x.x
Asked Answered
T

8

9

I am working to setup wiremock for springboot rest api and using rest assured and spring-cloud-starter-contract-stub-runner from spring cloud. when i run the sample integration test i encounter module conflict error

Tallu answered 5/5, 2022 at 11:17 Comment(0)
H
4

Found this workaround on Rest Assured's GitHub page. You replace Rest Assured's dependency with this one

<dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
        <exclusions><!-- https://www.baeldung.com/maven-version-collision -->
            <exclusion>
                <groupId>org.apache.groovy</groupId>
                <artifactId>groovy</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.groovy</groupId>
                <artifactId>groovy-xml</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>

Rest Assured's Github Page

Harriman answered 10/8, 2022 at 19:1 Comment(0)
T
3
  1. check your dependency tree of pom file. The reason for the error is there were two groovy libs in your class path with different versions and this is causing the conflict
  2. One from rest-assured dependency and other from spring-cloud-starter-contract-stub-runner dependency
  3. Solution is to remove rest assured and replace it with restdocs-api-spec-restassured dependency. This way you can use rest assured with out additional groovy dependency . your class path will only have 1 groovy from spring-cloud-starter-contract-stub-runner dependency
Tallu answered 5/5, 2022 at 11:17 Comment(0)
A
2

groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-xml is loaded in version 4.0.6 and you are trying to load version 3.0.19

implementation ("io.rest-assured:rest-assured") {
    exclude group: "org.apache.groovy", module: "groovy"
    exclude group: "org.apache.groovy", module: "groovy-xml"
}
Antonia answered 29/9, 2023 at 8:10 Comment(0)
T
1
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>${restassured.version}</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-xml</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Tanto answered 5/3, 2023 at 14:0 Comment(0)
V
0

1 just manually remove rest-assured dependency from POM file.

2 add to the pom file

<dependency>
        <groupId>com.epages</groupId>
        <artifactId>restdocs-api-spec-restassured</artifactId>
        <version>0.10.4</version>
    </dependency>

3 Maven clean

4 Maven Compile

5 Maven - Reload(refresh)

Vascular answered 29/7, 2022 at 13:28 Comment(0)
G
0

Gradle dependencies:

testImplementation('io.rest-assured:rest-assured:5.3.0')  {
    exclude group: 'org.apache.groovy', module: 'groovy'
    exclude group: 'org.apache.groovy', module: 'groovy-xml'
}
Ganglion answered 15/6, 2023 at 22:2 Comment(0)
D
0

Remove the groovy related dependencies and try to run your project, hopefully it will solve the problem. Make sure that you are using the latest version of rest-assure i.e 5.1.1 or later on

Delila answered 21/12, 2023 at 4:45 Comment(0)
J
0
  1. Remove lower version of dependency
  2. Add below version to pom.xml file

Rest Assured version 5.3.0

Jaggery answered 20/4, 2024 at 19:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.