Skip to content

The Jakarta JAXB migration adds a JAXB runtime to modules that create a JAXBContext - #1267

Merged
jkschneider merged 2 commits into
jakarta/jaxws-api-for-importsfrom
jakarta/jaxb-runtime-provider
Oct 4, 2026
Merged

jkschneider merged 2 commits into
jakarta/jaxws-api-for-importsfrom
jakarta/jaxb-runtime-provider

Conversation

@jkschneider

Copy link
Copy Markdown
Member

On Java 8, JAXBContext.newInstance finds the JDK's built-in provider, which implements only javax.xml.bind, so after the migration a standalone application compiles against jakarta.xml.bind but fails at runtime with ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory. New scanning recipe AddJakartaXmlBindRuntime, run in JavaxXmlBindMigrationToJakartaXmlBind right after the API is added, finds JAXBContext.newInstance calls, typed or matched through the import when the type is unresolved, and adds org.glassfish.jaxb:jaxb-runtime:3.0.x to the nearest Maven module in runtime scope, or test scope when only tests make the call. It skips modules that already have a provider (GlassFish jaxb-runtime, Sun jaxb-impl, EclipseLink MOXy), that declare a Java EE or Jakarta EE platform API as provided, or that are packaged as war or ear, and modules that only use the JAXB annotations get nothing. #1257 has no counterpart to this: the Java 11 migration adds a runtime through AddJaxbRuntime, and the Jakarta migration had none.

Found by a team of coding agents reviewing a Moderne run of org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta over the 31 Arquillian repositories (run 20261003120559-YQoma). The issue is jaxb-runtime-missing-java8 in the run's io.moderne.RecipeIssues data table (2 rows), and the fix was discussed and reviewed on the run's message board. A row from the table, as a generalized example:

Migrating Java 8 JAXB factory calls leaves standalone applications without a Jakarta JAXB provider. (arquillian/arquillian-rusheye, rusheye-impl/pom.xml, recipe org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta)

Before:

Java 8; javax.xml.bind.JAXBContext.newInstance(A.class);

What the recipe produced:

Jakarta API only; jakarta.xml.bind.JAXBContext.newInstance(A.class);

Expected:

org.glassfish.jaxb:jaxb-runtime:3.0.2 runtime dependency; jakarta.xml.bind.JAXBContext.newInstance(A.class);

Stacked on #1266 (4 of 19); merge that one first.

@jkschneider
jkschneider force-pushed the jakarta/jaxb-runtime-provider branch from e7e14e2 to d679785 Compare October 3, 2026 22:26
@jkschneider
jkschneider added this pull request to stack #1284 October 4, 2026 09:43
@jkschneider
jkschneider merged commit f88159d into main Oct 4, 2026
1 check passed
@jkschneider
jkschneider deleted the jakarta/jaxb-runtime-provider branch October 4, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant