Skip to content

Migrate web.xml xsi:schemaLocation from J2EE 1.4 namespace - #1177

Merged
steve-aom-elliott merged 1 commit into
mainfrom
fix-web-xml-j2ee-schema-location
Jul 27, 2026
Merged

Migrate web.xml xsi:schemaLocation from J2EE 1.4 namespace#1177
steve-aom-elliott merged 1 commit into
mainfrom
fix-web-xml-j2ee-schema-location

Conversation

@steve-aom-elliott

@steve-aom-elliott steve-aom-elliott commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The JavaxWebXmlToJakartaWebXml recipe updated xmlns and version attributes on J2EE 1.4 web.xml descriptors (http://java.sun.com/xml/ns/j2ee, version="2.4") but left xsi:schemaLocation pointing at the old j2ee schema. The ChangeTagAttribute step for xsi:schemaLocation gated on a regex (?s).*xml/ns/javaee.* that only matched the newer javaee namespace, so J2EE 1.4 descriptors fell through and produced this inconsistent output:

<web-app version="5.0"
         xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

Broaden the regex to (?s).*xml/ns/(j2ee|javaee).* so J2EE 1.4 descriptors also have xsi:schemaLocation rewritten to the Jakarta EE 9 web-app_5_0.xsd, per the Eclipse Foundation's Jakarta EE XML Schemas index (Jakarta EE 9+ descriptors share the https://jakarta.ee/xml/ns/jakartaee namespace, and web-app_5_0.xsd is the Servlet 5.0 deployment descriptor schema).

Sibling recipes for faces-config, facelet-taglib, and web-fragment overwrite xsi:schemaLocation unconditionally (no oldValue), so they don't have this bug. Added a migrateJ2ee test covering the 2.4 → 5.0 case.

The web.xml Jakarta migration updated xmlns and version attributes on
J2EE 1.4 descriptors (http://java.sun.com/xml/ns/j2ee) but left the
xsi:schemaLocation pointing at the old j2ee schema, because the
oldValue regex only matched the newer 'javaee' namespace. Broaden the
regex to also match 'j2ee' so schemaLocation is rewritten to the
Jakarta EE 9 web-app_5_0.xsd.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jul 27, 2026
@steve-aom-elliott steve-aom-elliott added bug Something isn't working test provided recipe Recipe requested labels Jul 27, 2026
@steve-aom-elliott steve-aom-elliott moved this from In Progress to Ready to Review in OpenRewrite Jul 27, 2026
@steve-aom-elliott
steve-aom-elliott merged commit 39b31e8 into main Jul 27, 2026
1 check passed
@steve-aom-elliott
steve-aom-elliott deleted the fix-web-xml-j2ee-schema-location branch July 27, 2026 18:09
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working recipe Recipe requested test provided

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant