4

I tried to validate a JWT authentication token,

JWTVerifier verifier = JWT.require(Algorithm.HMAC256("secret")).withIssuer("siat").build();
String token=httpRequest.getParameter("token");
DecodedJWT decodedJWT = verifier.verify(token);

following is exception stack trace:

java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JsonNode.asText(Ljava/lang/String;)Ljava/lang/String;
CHHIBI AMOR
  • 1,186
  • 2
  • 13
  • 27

2 Answers2

5

Check your dependency graph whether it is pulling the correct version of Jackson-databind jar

The method it complains is available in version 2.4.0 onwards of jackson-databind.jar

If somehow you have the older version of jar in your classpath then it wouldn't serve the needed method.

Rizwan
  • 2,369
  • 22
  • 27
1

If you check the java-jwt dependencies in any maven repository, for example in MVN Repository you'll se between the compile dependencies the required version of jackson-databind (that is the one throwing the java.lang.NoSuchMethodError exception).

In your case, for java-jwt 3.1.0 version you must have jackson-databind version 2.8.4 or the new one 2.9.0.

Valerio Emanuele
  • 909
  • 13
  • 27