Quick revision
The short answer
I would start with an inventory of which services use javax.xml.bind, which libraries depend on it and which use generated classes, then migrate the shared XML model libraries first and publish them in parallel javax and jakarta versions for a transition period. Each service then upgrades its build plugins, regenerates classes with Jakarta namespaces, rewrites hand-written imports with OpenRewrite, and proves nothing changed by replaying recorded production messages with schema validation. The work is scheduled together with Spring Boot 3 or 4 upgrades, which force Jakarta anyway.
What to remember
In this answer, we saw that javax and jakarta annotations are different classes, so mixing them inside a service fails silently, while services can move one at a time. We planned the migration as an inventory first, shared model libraries next with parallel javax and jakarta versions and an end date, and then each service with new dependencies, regenerated classes, OpenRewrite for imports and updated configuration. We proved behaviour with recorded production messages and schema validation, and scheduled the work with Spring Boot 3 or 4 upgrades.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would start with an inventory of which services use javax.xml.bind, which libraries depend on it and which use generated classes, then migrate the shared XML model libraries first and publish them in parallel javax and jakarta versions for a transition period. Each service then upgrades its build plugins, regenerates classes with Jakarta namespaces, rewrites hand-written imports with OpenRewrite, and proves nothing changed by replaying recorded production messages with schema validation. The work is scheduled together with Spring Boot 3 or 4 upgrades, which force Jakarta anyway.
Why this question is asked
A namespace migration sounds mechanical: replace javax with jakarta and rebuild. With 40 services that exchange XML with banks and government systems, it is not. Generated classes, shared model libraries, SOAP stacks and partner certification all get in the way, and a subtle change in output can cause a rejected payment file. Interviewers ask this scenario to see whether we can plan a migration that is safe and finishes, rather than one that stalls halfway with both namespaces everywhere. In this answer, we will see why javax and jakarta cannot simply coexist, build the inventory, decide the order of migration, go through the steps for one service, and plan the testing that proves behaviour did not change.
1Why the Two Namespaces Do Not Mix
Jakarta EE 9 renamed every package from javax.* to jakarta.*, so jakarta.xml.bind.annotation.XmlElement and javax.xml.bind.annotation.XmlElement are completely different classes to the JVM. A jakarta JAXB runtime does not see javax annotations at all, and vice versa. If a service on the jakarta runtime loads a model class annotated with javax annotations, JAXB treats it as an unannotated class and produces different XML, or fails, with no compile error to warn us.
That is the core risk of this migration: mixing generations within one service does not fail loudly. So each service must move all its XML code, its generated classes and the libraries it uses that expose JAXB types, at the same time, while services can move one by one because they talk to each other through XML text, not Java types.
2Building the Inventory
Before planning, we need facts. A script over all 40 repositories collects, for each service: does it import javax.xml.bind or jakarta.xml.bind, which JAXB runtime version and which code-generation plugin it uses, which XSDs it generates from, which internal libraries with JAXB types it depends on, which partner integrations it serves, and its Spring Boot version. Dependency trees from Maven or Gradle show libraries that bring javax.xml.bind transitively, such as old SOAP clients.
| Group | Services | Notes |
|---|---|---|
| Already jakarta | 20 | done; check no javax libraries remain |
| javax, generated classes only | 11 | regenerate with a Jakarta plugin |
| javax, hand-written models | 5 | OpenRewrite for imports, review package-info |
| javax via shared model libraries | 4 | blocked until the libraries ship jakarta |
| Using javax SOAP stack (JAX-WS) | 6 (overlap) | upgrade to a Jakarta XML Web Services stack too |
3Order of Migration: Shared Libraries First
Shared XML model libraries, for example a library of generated classes for a bank's payment schema used by eight services, are the bottleneck. A service cannot move to jakarta while it depends on a javax version of such a library. So the libraries go first, and we publish both versions in parallel for a transition period: the existing javax artifact, now frozen except for urgent fixes, and a new jakarta artifact built from the same XSD, with a clear name or classifier, for example payments-model-jakarta 3.0.0.
With both available, each consuming service can switch on its own schedule. We announce an end date for the javax artifacts, for example six months, and track who still uses them. Without that date, the parallel versions become permanent and every schema change must be made twice.
- Inventory all 40 services and their libraries
- Migrate shared model librariespublish javax and jakarta versions in parallel
- Migrate services one by onepreferably with their Spring Boot upgrade
- Replay recorded messages, validate against XSDscompare output with the javax version
- Deploy, watch partner rejections
- Retire javax artifacts on the announced date
6 steps in order. Play them, or step through them one at a time.
4Steps for One Service
For a service, the change has four parts. Dependencies: replace javax.xml.bind:jaxb-api and com.sun.xml.bind runtimes with jakarta.xml.bind-api and org.glassfish.jaxb:jaxb-runtime 4.0.x, and replace any javax SOAP stack with its Jakarta version. Code generation: switch to a plugin version that generates jakarta annotations, and regenerate from the same XSDs and binding files; old plugins only produce javax. Hand-written code: change imports in model classes, adapters, package-info.java files and the code that creates contexts. Configuration: update jaxb.properties files that name a context factory, and binding files whose namespace or version identifies the older JAXB.
The import changes are where automation pays off. OpenRewrite, a tool that applies refactoring recipes across a codebase, has migration recipes for javax to jakarta, including one for XML binding that changes imports and dependencies (check the exact recipe name in your OpenRewrite version). Running it as a Maven or Gradle plugin turns most of the hand edits into one command and a reviewable diff.
The final grep is a cheap but important check. Any javax.xml.bind left in source, in a resource file or in a dependency tree is a place where the two generations could meet silently.
5Proving Behaviour Did Not Change
For bank and government integrations, compiling is not evidence. The best evidence is real traffic. Before the migration, we collect a set of recorded production messages for each integration, anonymised where needed, covering the main message types and known edge cases. After the migration, a test unmarshals every recorded message, marshals it again, and validates the output against the partner's XSD. We also compare the new output with the output of the old javax version for the same objects, ignoring only insignificant differences such as namespace prefixes and whitespace.
This catches the changes that matter: a default value that now appears, a namespace that moved, an element order that changed because a regenerated class lost a propOrder, or a date written in a different format. Partners with certification environments get a test submission before the production switch, and after deployment we watch partner rejection rates closely for each service for the first days.
6Coordinating With Spring Boot Upgrades
Spring Boot 3 and 4 are built on Jakarta EE, so a service upgrading from Spring Boot 2 must move to jakarta for servlets, persistence and validation anyway, and its XML binding comes along. Doing both together means one round of testing and one deployment instead of two. So the migration schedule follows the Boot upgrade plan where possible, with XML-heavy services getting extra test time. Services that are not upgrading Boot soon, or that do not use Spring, are scheduled on their own, so nothing waits forever on another project.
7Follow-up questions
Can a service temporarily run both javax and jakarta JAXB?
Technically yes, if both APIs and runtimes are on the classpath and each model class is used only with its own context. In practice it is fragile and confusing, so it should be limited to a short transition inside one service with explicit tests, never a lasting state.
What about compiled third-party libraries that still use javax?
First look for a newer Jakarta release of the library. If none exists, the Eclipse Transformer can rewrite a compiled jar's references from javax to jakarta, which is a stopgap; the longer-term answer is to replace the library or isolate it in a separate service.
How do you keep the migration from stalling?
By tracking it like any programme: a list of the 40 services with status, owners and dates, a fixed end date for the parallel javax libraries, and a short weekly report. The automation and the shared test harness lower the cost for each team, which is what makes the deadline realistic.
8Conclusion
In this answer, we saw that javax and jakarta annotations are different classes, so mixing them inside a service fails silently, while services can move one at a time. We planned the migration as an inventory first, shared model libraries next with parallel javax and jakarta versions and an end date, and then each service with new dependencies, regenerated classes, OpenRewrite for imports and updated configuration. We proved behaviour with recorded production messages and schema validation, and scheduled the work with Spring Boot 3 or 4 upgrades.
Open with
First I would build an inventory across the 40 services: who imports javax or jakarta XML binding, which runtimes and code-generation plugins they use, which XSDs they generate from, which internal model libraries expose JAXB types, and their Spring Boot version.
Then, if they want more
The key risk is that javax and jakarta annotations are different classes, so a jakarta runtime silently ignores javax annotations; each service must move completely at once, but services can move independently because they exchange XML text.
Shared model libraries block the most services, so I would migrate those first and publish parallel javax and jakarta versions for a transition period with an announced end date.
For each service, I would switch to jakarta.xml.bind-api and jaxb-runtime 4.0, upgrade the code-generation plugin and regenerate classes, run an OpenRewrite javax-to-jakarta recipe for hand-written imports, and update package-info, jaxb.properties and binding files, then grep for any javax.xml.bind left.
To prove nothing changed, I would replay recorded production messages, validate the output against the partners' XSDs and compare it with the old output, plus test submissions where partners have certification environments. Where possible I would combine the work with Spring Boot 3 or 4 upgrades, since those force Jakarta anyway.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 3, Jakarta EE 9, Spring Boot 2
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Forty services exchange XML with banks and government systems through JAXB models, half...": https://scrivio-interview-library.netlify.app/java/jaxb/095d089976/