Wiremock: NoSuchField IGNORE_UNDEFINED

Created on 13 Feb 2017  路  9Comments  路  Source: tomakehurst/wiremock

Every time I try to run a junit test with @Rule annotation I've got java.lang.NoSuchFieldError: IGNORE_UNDEFINED Exception, I've also copied into my workspace your JUnit Example JUnitManaged.java as is and I've got the same problem.
Wiremock version imported via maven is 2.5.1

```
com.github.tomakehurst
wiremock
2.5.1

Most helpful comment

To solve this, I changed my pom to use the standalone instead:

        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>2.7.0</version>
            <scope>test</scope>
        </dependency>

All 9 comments

I suggest you check what else is on your classpath as this is almost certainly a clashing dependency. Using the standalone artifact is a good workaround for this type of problem.

```

com.googlecode.json-simple
json-simple
1.1


javax.json
javax.json-api
1.0



com.fasterxml.jackson.core
jackson-databind
${jackson.databind-version}

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0</version>
    </dependency>



    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.12</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>


    <!-- @Inject -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- Servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>


    <!-- Joda Time -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.9.1</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>

    <!-- AspectJ -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${org.aspectj-version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    <!-- SWAGGER -->
    <!-- <dependency> <groupId>com.wordnik</groupId> <artifactId>swagger-core</artifactId> 
        <scope>compile</scope> <version>1.5.1-M2</version> <exclusions> <exclusion> 
        <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> </exclusion> 
        </exclusions> </dependency> -->

    <!-- https://mvnrepository.com/artifact/io.swagger/swagger-jaxrs -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.4.0</version>
    </dependency>
    <!-- SWAGGER -->
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.4.0</version>
    </dependency>
    <!-- SL4J -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.22</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.22</version>
    </dependency>

    <!-- MAPDB -->
    <dependency>
        <groupId>org.mapdb</groupId>
        <artifactId>mapdb</artifactId>
        <version>3.0.3</version>
    </dependency>

    <!-- JUNIT -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework-version}</version>

    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
    </dependency>

    <!-- UNIT TEST REST -->
    <dependency>
        <groupId>com.github.tomakehurst</groupId>
        <artifactId>wiremock</artifactId>
        <version>2.5.1</version>
    </dependency>

Do you see anything that might create a conflict? Consider that I'm running a Spring mvc app with very basic setup and components.

Suggest you generate a maven dependency report and look for any that have been bumped up from the version required by WireMock by your other libs.

Or just try the standalone version as it shades most of the problematic dependencies.

@tsebastiani add dependency to 2.6.1,the field IGNORE_UNDEFINED is defined in object mapper only from version 2.6

```

com.fasterxml.jackson.core
jackson-core
2.6.1

```

@tomakesurst did adding dependency is the solution and is that the reason we wanted to close the issue. Since not an issue anymore ?

I closed it as it had been inactive since February and I've upgraded to the latest Jackson version (not released yet, but soon).

To solve this, I changed my pom to use the standalone instead:

        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>2.7.0</version>
            <scope>test</scope>
        </dependency>

I was facing dependency conflict with com.fasterxml.jackson.module.scala and probably for jetty also, all were resolved after changing towiremock-standalone.

Was this page helpful?
0 / 5 - 0 ratings