Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchFieldError "ADJUST_DATES_TO_CONTEXT_TIME_ZONE" when trying to parse json

I want to convert a json string containing a date into DateTime of jodaTime using jackson. Unfortunately I get this error

java.lang.NoSuchFieldError: ADJUST_DATES_TO_CONTEXT_TIME_ZONE

The json object looks like this:

{
"add_time": "2017-04-26 14:26:58",
}

I have included joda time and jackson as follows in my pom.xml:

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.9</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>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-joda</artifactId>
            <version>${jackson.version}</version>
        </dependency>

jackson version is 2.8.8. I've created my object mapper this way:

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());

Does anybody know what the problem might be? I'm stuck on this for a couple of hours now. I also tried do disable the DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE but it does not help.

like image 677
Martin Avatar asked Apr 27 '17 11:04

Martin


1 Answers

NoSuchFieldError results from class structure incompatibility of jackson library side, so you need to check the finally resolved library versions of jackson series.

like image 192
henoc Avatar answered Oct 31 '22 18:10

henoc