Jackson Error: java.lang.NoSuchMethodError: `com.fasterxml.jackson.databind.JsonNode.asText (Ljava / lang / String;) Ljava / lang / String`

I tried to check the JWT authentication token,

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

      

the following is the exception stack trace:

java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JsonNode.asText(Ljava/lang/String;)Ljava/lang/String;

      

+3


source to share


2 answers


Check the dependency graph to see if it will pull out the correct version of the Jackson-databind jar

The method he is complaining about is available in version 2.4.0 below jackson-databind.jar



If somehow you have an older version of the jar in your classpath, then it will not serve the required method.

+4


source


If you check the java-jwt dependencies in any maven repository, such as the MVN Repository , you will use the required jackson-databind version between the compilation dependencies (that is, the one that throws the java.lang.NoSuchMethodError exception).



In your case for java-jwt version 3.1.0 you must have jackson-databind version 2.8.4 or newer 2.9.0.

+1


source







All Articles