Quick revision
The short answer
Two things changed underneath the old client. Java 11 removed JAXB and JAX-WS from the JDK, so classes like javax.xml.bind and com.sun.xml.ws are no longer there for free, and Spring Boot 3 moved to Jakarta EE 9 and later, where those APIs live in the jakarta.xml.bind and jakarta.xml.ws packages. To migrate, regenerate the client classes with Jakarta-based tool versions, add the Jakarta implementations such as org.glassfish.jaxb:jaxb-runtime and a JAX-WS runtime like Metro or Apache CXF, or switch to Spring WS WebServiceTemplate with Jaxb2Marshaller, and test against recorded SOAP messages.
What to remember
In this answer, we saw that the old SOAP client broke for two reasons: Java 11 removed JAXB and JAX-WS from the JDK, and Spring Boot 3 moved to the Jakarta EE namespaces jakarta.xml.bind and jakarta.xml.ws. We regenerated the client with Jakarta-based plugins, added jaxb-runtime and one JAX-WS runtime such as Metro or Apache CXF, considered WebServiceTemplate with Jaxb2Marshaller as a lighter alternative, and protected the partner integration with tests built from recorded SOAP messages.
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.
Two things changed underneath the old client. Java 11 removed JAXB and JAX-WS from the JDK, so classes like javax.xml.bind and com.sun.xml.ws are no longer there for free, and Spring Boot 3 moved to Jakarta EE 9 and later, where those APIs live in the jakarta.xml.bind and jakarta.xml.ws packages. To migrate, regenerate the client classes with Jakarta-based tool versions, add the Jakarta implementations such as org.glassfish.jaxb:jaxb-runtime and a JAX-WS runtime like Metro or Apache CXF, or switch to Spring WS WebServiceTemplate with Jaxb2Marshaller, and test against recorded SOAP messages.
Why this question is asked
This is one of the most common breakages in a Spring Boot 3 upgrade, because SOAP clients are often generated once, checked in, and forgotten for a decade. The error messages point at missing packages, which makes people try to add the old javax jars back, and that leads to a second round of errors. Interviewers ask it to see whether we understand the two separate changes behind the failure. In this answer, we will see what was removed and what was renamed, reproduce the errors, regenerate the client, choose a runtime, look at the WebServiceTemplate alternative, and finish with how to test that nothing changed on the wire.
1What Changed: Removal and Renaming
The first change happened in the JDK. Up to Java 8, the JDK itself shipped JAXB, the API that maps XML to Java objects, and JAX-WS, the API for SOAP clients and services, together with their implementations in internal packages such as com.sun.xml.internal.ws. Java 9 deprecated these modules and Java 11 removed them completely. So code that compiled on Java 8 with no dependencies now needs those libraries added explicitly.
The second change came from Jakarta EE. When Java EE moved to the Eclipse Foundation, the APIs were renamed: from Jakarta EE 9 onward, javax.xml.bind became jakarta.xml.bind and javax.xml.ws became jakarta.xml.ws. Spring Boot 3 is built on Jakarta EE 9 and later, and Spring Web Services 4 uses the jakarta packages too. So simply adding the old javax JAXB jars back may make the code compile, but it will not work with the Jakarta-based libraries the rest of the application now uses.
| Piece | Java 8 era | Spring Boot 3 on Java 17 or 21 |
|---|---|---|
| JAXB API | inside the JDK, javax.xml.bind | jakarta.xml.bind-api dependency |
| JAXB runtime | inside the JDK | org.glassfish.jaxb:jaxb-runtime |
| JAX-WS API | inside the JDK, javax.xml.ws | jakarta.xml.ws-api dependency |
| JAX-WS runtime | inside the JDK, com.sun.xml.internal.ws | Metro (com.sun.xml.ws) or Apache CXF |
| Generated client classes | wsimport or xjc in the JDK | Jakarta plugin versions, jakarta imports |
2Reproducing the Errors
The generated classes still import the old packages, and nothing provides them any more.
The compile error comes from the missing API packages. The runtime error comes from the missing implementation: JAX-WS API classes look up a provider class at startup, and the one that used to be inside the JDK is gone. The exact class name in the message varies with the API version, so check your stack trace.
3Regenerating the Client for Jakarta
The clean fix is to regenerate the client from the partner's WSDL with tool versions that produce jakarta imports, and to stop checking generated code into the repository so this never drifts again. Both common toolchains have Jakarta versions: the JAX-WS wsimport Maven plugin from the Metro project in its Jakarta-era releases, and Apache CXF's cxf-codegen-plugin from CXF 4 onward. For plain JAXB classes from an XSD, the jaxb Maven plugins in their Jakarta releases do the same job.
If the generated code was hand-edited over the years, which happens, we should compare the old and new classes and move any custom logic out into wrapper code before deleting the old ones.
4Adding a Runtime
Generated code needs implementations at runtime. For JAXB, that is org.glassfish.jaxb:jaxb-runtime, whose version Spring Boot manages. For JAX-WS, we choose one runtime: Metro, the reference implementation, through com.sun.xml.ws:jaxws-rt, or Apache CXF with its JAX-WS frontend and HTTP transport. CXF is a good choice when we also need WS-Security, WS-Addressing or detailed logging of messages, and it has a Spring Boot starter. We should pick one and not mix them, because both register as the JAX-WS provider.
5Alternative: Spring WS WebServiceTemplate
If the application already uses Spring and only calls a few operations, we may not need JAX-WS at all. Spring Web Services provides WebServiceTemplate, a client that sends a payload object and receives the response, using a Marshaller to convert between objects and XML. With Jaxb2Marshaller from spring-oxm, we only need JAXB classes generated from the XSD part of the WSDL, not a full JAX-WS client.
This keeps the SOAP code inside the Spring stack we already upgrade together, with interceptors for logging and WS-Security, and avoids a second SOAP framework in the application.
6Testing That Nothing Changed on the Wire
A regenerated client can compile and still send a slightly different message: a namespace prefix moved, an element now nillable, a date with a different time zone format, or a missing SOAPAction header. Partners' servers are often strict, so these differences cause faults in production.
So before the upgrade we record real request and response messages from the old client, for example by logging them in a test environment, and keep them as fixtures. After the upgrade we compare the new client's outgoing XML with the recorded requests, ignoring harmless differences such as prefix names, and run the recorded responses through the new unmarshalling to check that every field still arrives. A stub server such as WireMock, or MockWebServiceServer from Spring WS, can replay the partner's responses in an automated test.
7Follow-up questions
Can we just add the old javax.xml.bind jars and keep the generated code?
It can make the code compile, but it leaves the application with two incompatible XML binding stacks: javax for the old client and jakarta for Spring and everything else. Spring WS 4, Jakarta implementations and Boot's managed versions will not work with the javax classes, so errors move from compile time to runtime. It is at best a short bridge, not a migration.
Why does the runtime fail with com.sun.xml.ws rather than a JAXB error?
Because the JAX-WS API is only a set of interfaces. At startup it looks for an implementation provider class, which used to be inside the JDK. When no implementation such as Metro or CXF is on the classpath, that lookup fails with a ClassNotFoundException or a WebServiceException mentioning the provider class.
Should the generated classes be committed to the repository?
Usually not. Generating them in the build from the WSDL keeps them in step with the contract and the tool version, and makes upgrades like this one a change to a plugin version instead of a search through thousands of generated lines.
8Conclusion
In this answer, we saw that the old SOAP client broke for two reasons: Java 11 removed JAXB and JAX-WS from the JDK, and Spring Boot 3 moved to the Jakarta EE namespaces jakarta.xml.bind and jakarta.xml.ws. We regenerated the client with Jakarta-based plugins, added jaxb-runtime and one JAX-WS runtime such as Metro or Apache CXF, considered WebServiceTemplate with Jaxb2Marshaller as a lighter alternative, and protected the partner integration with tests built from recorded SOAP messages.
Open with
There are really two changes behind these errors. First, Java 11 removed JAXB and JAX-WS from the JDK. On Java 8 the client compiled with no dependencies because javax.xml.bind and the JAX-WS implementation were built in; now they are simply not there, which is why the runtime cannot find the com.sun.xml.ws provider.
Then, if they want more
Second, Spring Boot 3 is on Jakarta EE 9 and later, so the APIs are now jakarta.xml.bind and jakarta.xml.ws, and Spring WS 4 uses those too. Adding the old javax jars back is a trap, because then we have two incompatible stacks.
So I would regenerate the client from the WSDL with Jakarta-era tools, for example cxf-codegen-plugin 4 or a Jakarta release of the wsimport plugin, and generate it in the build rather than committing it. Then I add the implementations: jaxb-runtime from GlassFish, and one JAX-WS runtime, Metro or Apache CXF.
If we only call a few operations and already use Spring, an alternative is WebServiceTemplate with Jaxb2Marshaller, which only needs the JAXB classes. Finally I would record real requests and responses from the old client and compare the new client's XML against them, because namespaces, nillable elements or the SOAPAction header can change and strict partner servers will reject that.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 3, Jakarta EE 9, Java 11, Java 8
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Spring Web MVC
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 "After upgrading to Spring Boot 3, a SOAP client generated years ago fails to compile...": https://scrivio-interview-library.netlify.app/spring-boot/web-other/b443ab75ab/