Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectMapper java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z

I am trying to map a Json string to a Java Object using ObjectMapper

ObjectMapper mapper = new ObjectMapper();
CustomerData customerData = mapper.readValue(customerDataString, customerData.class);

But when I do, I get this error

java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:530)

I looked online and checked for the incompatible dependencies in the pom.xml, and it appears to be the right version. So what am I missing?

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.6.0</version>
    </dependency>
like image 955
William Roberts Avatar asked Jan 29 '16 22:01

William Roberts


2 Answers

Following dependencies must be tally with each other. (Same Version)

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>${jackson.version}</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>${jackson.version}</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>${jackson.version}</version>
</dependency>
like image 65
Chinthaka Dinadasa Avatar answered Oct 07 '22 23:10

Chinthaka Dinadasa


Make sure that you do not have an older version of artifactId "jackson-core" (< 2.3.0) as a dependency. You can try to add

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.6.0</version> 
</dependency>

as first dependency in your pom.

like image 24
Rainer Montag Avatar answered Oct 08 '22 00:10

Rainer Montag