Search code examples
javajacksonjerseyjwt

JWTParser - NoSuchMethodError - ObjectMapper.readerFor


I'm getting the below error while trying to create JWTVerifier object in order to decode the token. Can you please help me understand what could be the root cause? Thanks in advance.

java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.readerFor(Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/ObjectReader;
at com.auth0.jwt.impl.JWTParser.<init>(JWTParser.java:25)
at com.auth0.jwt.impl.JWTParser.<init>(JWTParser.java:20)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:27)
at com.auth0.jwt.JWT.decode(JWT.java:45)

Solution

  • I believe, you are using the wrong jackson-databind library version. The error you see appears, when you have a library containing a class but the class is missing a method. Why? Well, probably the method is not in the version you are using or has been deprecated and removed.

    Please check your maven/gradle/whatever you are using and play with the version definition a bit. If this does not help, see the output of mvn dependency:tree or similar in the build tool of your choice.