Back to Java 11 Features
Q5Question 5 of 5

What breaks when upgrading Java 8 to 11?

Key Concepts
  • Java 11 removed six Java EE modules that were bundled in JDK 8: JAXB, JAX-WS, JAF, Common Annotations, CORBA, JTA
  • Code using javax.xml.bind, javax.annotation.PostConstruct, or SOAP fails with ClassNotFoundException
  • Fix: add explicit Maven/Gradle dependencies for Jakarta EE equivalents (jakarta.xml.bind-api)
  • The javax.* namespace migrated to jakarta.* in Jakarta EE 9+
  • Run jdeps --jdk-internals on your JAR before upgrading to find uses of removed modules and internal APIs
  • Spring Boot 3.x already includes these as transitive dependencies

Definition

Java 11 removed six Java EE modules (JAXB, JAX-WS, JAF, Common Annotations, CORBA, JTA) that were bundled in JDK 8, causing ClassNotFoundException for code that used them without explicit dependencies.
  • Removed modules: java.xml.bind (JAXB), java.xml.ws (JAX-WS/SOAP), java.activation (JAF), java.xml.ws.annotation (Common Annotations), java.corba (CORBA), java.transaction (JTA).
  • Symptoms: ClassNotFoundException or NoClassDefFoundError for classes like javax.xml.bind.JAXBContext or javax.annotation.PostConstruct.
  • Fix: add explicit Maven/Gradle dependencies for the Jakarta EE equivalents.
  • Namespace migration: javax.* packages moved to jakarta.* in Jakarta EE 9+.
  • Detection: run jdeps --jdk-internals your.jar before upgrading to find problematic dependencies.
  • Spring Boot 3.x includes these as transitive dependencies, but standalone applications must add them manually.

Java 8 was a building with a cafeteria, gym, and childcare (Java EE modules) included free. Java 11 removed them: "These services are available across the street (Maven Central). We are not bundling them anymore." If your code relied on the in-building cafeteria (JAXB for XML), it breaks until you order food delivery (add the Maven dependency).

Understanding the Concepts

What was removed?

Java 11 removed six modules that were deprecated for removal in Java 9 and deleted in Java 11.

| Module | Provides | Common Classes |
|--------|---------|----------------|
| java.xml.bind | JAXB (XML binding) | JAXBContext, Marshaller |
| java.xml.ws | JAX-WS (SOAP) | Service, @WebService |
| java.activation | JAF | DataHandler |
| java.xml.ws.annotation | Common Annotations | @PostConstruct, @Resource |
| java.corba | CORBA | ORB, IIOP |
| java.transaction | JTA | @Transactional (JTA version) |

What error do you see?

TEXT
java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext

or

TEXT
java.lang.NoClassDefFoundError: javax/annotation/PostConstruct

How do you fix it?

Add explicit dependencies in your build file.

XML
<!-- Maven: JAXB API + runtime --syn-kw">>
syn-kw"><dependencysyn-kw">>
    syn-kw"><groupIdsyn-kw">>jakarta.xml.bindsyn-kw"></groupIdsyn-kw">>
    syn-kw"><artifactIdsyn-kw">>jakarta.xml.bind-apisyn-kw"></artifactIdsyn-kw">>
    syn-kw"><versionsyn-kw">>4.0.2syn-kw"></versionsyn-kw">>
syn-kw"></dependencysyn-kw">>
syn-kw"><dependencysyn-kw">>
    syn-kw"><groupIdsyn-kw">>org.glassfish.jaxbsyn-kw"></groupIdsyn-kw">>
    syn-kw"><artifactIdsyn-kw">>jaxb-runtimesyn-kw"></artifactIdsyn-kw">>
    syn-kw"><versionsyn-kw">>4.0.5syn-kw"></versionsyn-kw">>
syn-kw"></dependencysyn-kw">>

<!-- Maven: Common Annotations (@PostConstruct) --syn-kw">>
syn-kw"><dependencysyn-kw">>
    syn-kw"><groupIdsyn-kw">>jakarta.annotationsyn-kw"></groupIdsyn-kw">>
    syn-kw"><artifactIdsyn-kw">>jakarta.annotation-apisyn-kw"></artifactIdsyn-kw">>
    syn-kw"><versionsyn-kw">>3.0.0syn-kw"></versionsyn-kw">>
syn-kw"></dependencysyn-kw">>

How do you detect problems before upgrading?

BASH
# Scan your JAR for removed API usage
jdeps --jdk-internals banking-service.jar

# Look for javax.xml.bind, javax.annotation, etc.

What about the javax to jakarta namespace change?

Jakarta EE 9+ changed the package namespace from javax.* to jakarta.*. If you upgrade to Jakarta EE 10 (used by Spring Boot 3.x), you must change all imports.

JAVA
// Before (javax)
import javax.annotation.PostConstruct;
import javax.xml.bind.JAXBContext;

// After (jakarta)
import jakarta.annotation.PostConstruct;
import jakarta.xml.bind.JAXBContext;

What other changes affect the upgrade?

  • Default GC changed from Parallel to G1 (since Java 9). Tuning parameters may differ.
  • Some internal sun.* APIs are inaccessible under the module system.
  • java.security.acl package was removed.
  • Nashorn JavaScript engine was deprecated (removed in Java 15).

What are common mistakes?

WRONG: Adding the old javax.xml.bind:jaxb-api dependency instead of the Jakarta version.

WRONG: Not testing the full application after upgrading. Some failures only appear at runtime.

What should a senior engineer know?

  • This is the single most common Java 8 to 11 migration issue.
  • Spring Boot 2.x still uses javax.*. Spring Boot 3.x uses jakarta.*. Upgrading Spring Boot versions requires the namespace change.
  • The --add-modules flag can temporarily re-add deprecated modules in Java 9 and 10, but this does not work in Java 11 because the modules are fully removed.
  • For legacy systems that cannot change, consider using JDK 8 compatible JAXB implementations from Maven Central while keeping the javax.* imports.

Visual Overview

DIAGRAM
  Java 8 JDK                     Java 11 JDK
  ┌─────────────────────┐       ┌─────────────────────┐
  │ Core Java           │       │ Core Java           │
  │ + JAXB              │       │                     │
  │ + JAX-WS            │  ──→  │ (JAXB removed)      │
  │ + JAF               │       │ (JAX-WS removed)    │
  │ + Annotations       │       │ (CORBA removed)     │
  │ + CORBA             │       │                     │
  │ + JTA               │       │                     │
  └─────────────────────┘       └─────────────────────┘
                                         │
                                  Fix: add Maven deps
                                         │
                                         ▼
                                ┌─────────────────────┐
                                │ jakarta.xml.bind-api │
                                │ jakarta.annotation   │
                                │ (from Maven Central) │
                                └─────────────────────┘

Key Takeaway

A Java 8 to 11 upgrade commonly breaks builds because Java 11 removed six Java EE modules that were bundled in JDK 8: JAXB, JAX-WS, JAF, Common Annotations, CORBA, and JTA. Code using @PostConstruct, JAXB marshalling, or SOAP clients gets ClassNotFoundException.

The fix is adding explicit Maven dependencies for the Jakarta EE equivalents. The javax.* namespace migrated to jakarta.* in Jakarta EE 9+. Spring Boot 3.x already includes these as transitive dependencies, but standalone applications must add them manually.

At National Bank of India, a legacy XML settlement service breaks on Java 11 because JAXB is no longer bundled. Adding jakarta.xml.bind-api and jaxb-runtime as dependencies resolves the issue.

Remember one sentence: Java 11 removed JAXB and five other Java EE modules; add them back as explicit Jakarta dependencies from Maven Central.

---

Share
Use ← → arrow keys to navigate