CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > How to > How to Fix NoClassDefFoundError: javax/xml/bind/DatatypeConverter in Java (Java 11+)

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor
  • Home

How to Fix NoClassDefFoundError: javax/xml/bind/DatatypeConverter in Java (Java 11+)

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 Β· 3 min read Β· 0 Comments
Share: in X

While upgrading Java applications from Java 8 to Java 11 or later, many developers encounter the following runtime error:

Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

This issue is very common in Spring Boot, microservices, JWT-based authentication, and SOAP/JAX-WS clients. The error occurs because certain Java EE modules were removed from the JDK starting with Java 9.

In this article, you’ll learn why this error happens, how to fix it correctly, and which solution is best for production applications.

Table of Contents

  • Real-World Use Case
  • Why This Error Occurs
    • Java Version Behavior
  • Solution 1: Add JAXB Dependency (Recommended)
    • Maven Configuration
    • Gradle Configuration
  • Solution 2: Replace DatatypeConverter Usage (Best Practice)
    • ❌ Old Code (JAXB)
    • βœ… New Code (Java Built-in)
    • Decode Example
  • Libraries That Commonly Cause This Error
  • Best Practices & Recommendations
  • Summary
  • FAQs
    • Is this error specific to Spring Boot?
    • Which solution is best for production?
    • Can I downgrade Java to fix this?

Real-World Use Case

You may see this error when:

  • Migrating a Spring Boot app from Java 8 β†’ Java 11 and Later versions
  • Running JWT authentication libraries
  • Using SOAP or XML-based APIs
  • Deploying microservices on Docker with Java 17

Even though your code compiles successfully, the application fails at runtime, making this issue confusing for many developers.

Why This Error Occurs

javax.xml.bind.DatatypeConverter belongs to JAXB (Java XML Binding).

Java Version Behavior

Java VersionJAXB Availability
Java 8Included by default
Java 9–10Optional module
Java 11+Completely removed

So when your application or dependency tries to load JAXB classes on Java 11+, the JVM throws:

NoClassDefFoundError

Solution 1: Add JAXB Dependency (Recommended)

This is the best and safest solution for Java 11, 17, and newer versions.

Maven Configuration

<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>2.3.3</version>
</dependency>

<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.3</version>
</dependency>

Gradle Configuration

implementation 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.3'

βœ… Works with Java 11, 17, 21
βœ… Production-safe
βœ… Recommended for Spring Boot & Microservices

Solution 2: Replace DatatypeConverter Usage (Best Practice)

If your own code is using DatatypeConverter, you can remove JAXB completely.

❌ Old Code (JAXB)

DatatypeConverter.printBase64Binary(bytes);

βœ… New Code (Java Built-in)

import java.util.Base64;String encoded = Base64.getEncoder().encodeToString(bytes);

Decode Example

byte[] decoded = Base64.getDecoder().decode(encoded);

βœ… No external dependency
βœ… Cleaner and faster
βœ… Future-proof

Libraries That Commonly Cause This Error

  • JWT libraries (io.jsonwebtoken)
  • SOAP / JAX-WS clients
  • Older Jackson XML modules
  • Legacy Spring Boot projects

Best Practices & Recommendations

βœ” Prefer dependency-based solution for Java 11+
βœ” Replace JAXB APIs if only Base64 functionality is needed

Summary

In this tutorial, you learned:

  • Why NoClassDefFoundError: javax/xml/bind/DatatypeConverter occurs
  • How Java removed JAXB after Java 8
  • Two proven solutions to fix the issue
  • Best practices for modern Java applications

If you’re upgrading Java versions, this fix will save you hours of debugging time.

FAQs

Is this error specific to Spring Boot?

No. Any Java application running on Java 11+ can face this issue.

Which solution is best for production?

Adding JAXB dependencies is the safest and recommended approach.

Can I downgrade Java to fix this?

You can, but it’s not recommended. Always prefer forward-compatible solutions.

Related Posts:

  • Most Frequently Asked Spring Boot Interview…
  • Install and Set Up Java Development Environment
  • Control Statements in Java
  • How to Connect Java Application to a Remote Database…
  • Top 10 Common Java Errors
  • Integrate Spring AI with DeepSeek AI
Tags:how-tojava
Was this article helpful?
← Previous ArticleHow to Connect Java Application to a Remote Database Using an SSH Tunnel (with Spring Boot Examples)
Next Article β†’How to Fix Files Showing as Modified in IntelliJ IDEA on macOS

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
Β© 2026 CoderSathi. All rights reserved. Privacy Policy Β· Sitemap