I recently upgraded my application from Spring 2 -> Spring 3. However I seem not to be able to get past an io.jwt error…
:"ERROR","level_value":40000,"stack_trace":"java.lang.NoSuchMethodError: 'io.jsonwebtoken.JwtParser io.jsonwebtoken.Jwts.parser()'
Looking further into the error I see the error is coming from a jar file that I am importing from another team…
"ERROR","level_value":40000,"stack_trace":"java.lang.NoSuchMethodError: 'io.jsonwebtoken.JwtParser io.jsonwebtoken.Jwts.parser()'ntat ppd.product.auth.JwtTokenUtil.getAllClaimsFromToken(JwtTokenUtil.java:73)ntat ppd.product.auth.JwtTokenUtil.getClaimFromToken(JwtTokenUtil.java:45)ntat ppd.product.auth.JwtTokenUtil.getUsernameFromToken(JwtTokenUtil.java:37)ntat ppd.product.auth.JwtRequestFilter.doFilterInternal(JwtRequestFilter.java:33)
in the jar file the method it is complaining about is
private <T> T getCustomClaimFromToken(String token, String key) {
Claims claims = this.getAllClaimsFromToken(token);
return claims.get(key);
}
I thought it could be related to javax not being jakarta however this class is using jakarta
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.function.Function;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
mvn dependency:tree
io.jsonwebtoken:jjwt-api:jar:0.12.5:compile
[INFO] +- com.google.auth:google-auth-library-oauth2-http:jar:1.23.0:compile
[INFO] | +- com.google.auto.value:auto-value-annotations:jar:1.10.4:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | +- com.google.auth:google-auth-library-credentials:jar:1.23.0:compile
[INFO] | +- com.google.http-client:google-http-client:jar:1.44.1:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.14:compile
pom
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.5</version>
</dependency>
I tried importing different jjwt-api versions and jar with no avail.
Has anyone had a similar issue when upgrading to spring 3? Any advice would be greatly appreciated.