0

I have an issue. Tried to change the versions (like it says on the internet), but it didn't help.I get this error when i try to deploy project using docker composer

Problem:

The method's class, io.jsonwebtoken.SignatureAlgorithm, is available from the following 
 locations:
jar:file:/app/libs/jjwt-0.9.1.jar!/io/jsonwebtoken/SignatureAlgorithm.class
jar:file:/app/libs/jjwt-api-0.11.2.jar!/io/jsonwebtoken/SignatureAlgorithm.class
It was loaded from the following location:
    file:/app/libs/jjwt-0.9.1.jar

Console:


APPLICATION FAILED TO START


Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

io.jsonwebtoken.security.Keys.hmacShaKeyFor(Keys.java:84)

The following method did not exist:

io.jsonwebtoken.SignatureAlgorithm.getMinKeyLength()I

The method's class, io.jsonwebtoken.SignatureAlgorithm, is available from the following locations:

jar:file:/app/libs/jjwt-0.9.1.jar!/io/jsonwebtoken/SignatureAlgorithm.class
jar:file:/app/libs/jjwt-api-0.11.2.jar!/io/jsonwebtoken/SignatureAlgorithm.class

It was loaded from the following location:

file:/app/libs/jjwt-0.9.1.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of io.jsonwebtoken.SignatureAlgorithm

This is my pom.xml :

<dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-impl</artifactId>
        <version>0.11.2</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-jackson</artifactId>
        <version>0.11.2</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.1</version>
    </dependency>-->
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-api</artifactId>
        <version>0.11.2</version>
    </dependency>
  • 1
    Remove the jjwt artifact. According to the documentation (https://github.com/jwtk/jjwt#maven) you only need jjwt-api, jjwt-impl and jjwt-jackson – Sebastian Jan 08 '21 at 15:22
  • when i removed jjwt artifact i get errors in my code method Jwts.parserBuilder() not found the method exist only in jjwt – mohamed amine salah Jan 08 '21 at 15:32
  • 1
    The method was probably moved between versions. You might want to delete the old import after you removed the jjwt dependency and your IDE might find the correct new import. The Jwts class still exists and so does the method: https://github.com/jwtk/jjwt/blob/master/api/src/main/java/io/jsonwebtoken/Jwts.java – Sebastian Jan 08 '21 at 15:41
  • thx for your reply it work for me – mohamed amine salah Jan 09 '21 at 11:09
  • 1
    I provided an answer to properly resolve this issue. – Sebastian Jan 11 '21 at 10:02

1 Answers1

1

According to the documentation you only need the following dependencies:

<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-impl</artifactId>
    <version>0.11.2</version>
    <scope>runtime</scope>
</dependency>

<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-jackson</artifactId>
    <version>0.11.2</version>
    <scope>runtime</scope>
</dependency>

<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-api</artifactId>
    <version>0.11.2</version>
</dependency>

The missing class / method is Jwts.parserBuilder() still available but was probably moved between versions. Removing the import from the class and allowing your IDE to reimport it, should resolve this issue.

(see comments under question for context)

Sebastian
  • 858
  • 7
  • 21