Upgrading JJWT on Spring Boot 3.3.x for GraalVM and Cloud Native

posted 1 min read

Upgrading JJWT on Spring Boot 3.3.x

This article aims to provide details on how to fix JJWT exceptions when running the Cloud Native image, built with GraalVM.

Based on recent changes, from JJWT version 0.12.7 and above, JJWT changed how builders are instantiated with reflection, please see this comment and thread if you wan't to learn more: https://github.com/jwtk/jjwt/issues/637#issuecomment-2825061536

Basically:

Note that via the merge of #989, the (not yet released) 0.12.7 version and later changes how builders are instantiated via reflection. I'm not a graal user myself, but I wanted to make a note of that here in case the changes in #989 impact graal environments.

So, if you need JJWT on recent versions of Spring Boot and wants to compile to Cloud Native with GraalVM, here's what you need to do:

Update the resources/META-INF/native-image/reflect-config.json file adding the code below (if you don't have the file yet, create one):

 {
    "name": "io.jsonwebtoken.impl.DefaultJwtHeaderBuilder$Supplier",
    "methods": [
      {
        "name": "<init>",
        "parameterTypes": []
      }
    ]
  },
  {
    "name": "io.jsonwebtoken.impl.DefaultClaimsBuilder$Supplier",
    "methods": [
      {
        "name": "<init>",
        "parameterTypes": []
      }
    ]
  },
  {
    "name": "io.jsonwebtoken.impl.security.DefaultKeyOperationBuilder$Supplier",
    "methods": [
      {
        "name": "<init>",
        "parameterTypes": []
      }
    ]
  },
  {
    "name": "io.jsonwebtoken.impl.security.DefaultKeyOperationPolicyBuilder$Supplier",
    "methods": [
      {
        "name": "<init>",
        "parameterTypes": []
      }
    ]
  }

Note that you might need more reflection configuration depending on your case.

As a resource, I'd like to keep my code as reference, here's the PR upgrading Spring Boot to version 3.5.5 and JJWT to 0.13.0 (the latest versions in the time of this writing). Find the changes here: https://github.com/ricardo-campos-org/react-typescript-todolist/pull/631

0 votes
0 votes

More Posts

Let's understand Retries in Spring Boot

Madhu - Oct 17, 2025

Designing APIs for the AI Era with Spring AI and MCP

David Lopez Felguera - Sep 22, 2025

Optimizing the Clinical Interface: Data Management for Efficient Medical Outcomes

Huifer - Jan 26

Distributed Tracing in Spring Boot: A Practical Guide to OpenTelemetry and Jaeger

Raj Kundalia - Jan 31

POJO-actor Tutorial Part 2-3: Improving the Workflow API — Introducing the @Action Annotation

devteam2512 - Jan 28
chevron_left