Definition
- 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:
ClassNotFoundExceptionorNoClassDefFoundErrorfor classes likejavax.xml.bind.JAXBContextorjavax.annotation.PostConstruct. - Fix: add explicit Maven/Gradle dependencies for the Jakarta EE equivalents.
- Namespace migration:
javax.*packages moved tojakarta.*in Jakarta EE 9+. - Detection: run
jdeps --jdk-internals your.jarbefore 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?
java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
or
java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
How do you fix it?
Add explicit dependencies in your build file.
<!-- 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?
# 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.
// 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.aclpackage 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 usesjakarta.*. Upgrading Spring Boot versions requires the namespace change. - The
--add-modulesflag 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
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.
---