Markus Jung created TOMEE-4657:
----------------------------------
Summary: Bean Validation XML config fails on stock Plume: MOXy
beats JAXB RI in ServiceLoader
Key: TOMEE-4657
URL: https://issues.apache.org/jira/browse/TOMEE-4657
Project: TomEE
Issue Type: Bug
Components: TomEE Core Server
Reporter: Markus Jung
On an out-of-the-box TomEE 11 Plume server, every Bean Validation path that
reads {{validation.xml}} or constraint-mapping XML descriptors fails. Plume
ships two JAXB providers side by side: EclipseLink MOXy
({{eclipselink-5.0.1.jar}}) and the JAXB RI ({{jaxb-runtime-4.0.4.jar}}).
EclipseLink registers a {{jakarta.xml.bind.JAXBContextFactory}} service, and
ServiceLoader picks it over the JAXB RI.
The problem is a mismatch, not a missing feature. Apache BVal rewrites
namespaces while it parses {{validation.xml}} and constraint-mapping
descriptors. MOXy rejects that rewriting, so JAXBContext creation fails and the
whole XML-configuration path breaks. The JAXB RI does not have this problem; it
parses the rewritten descriptors fine.
The fix belongs in TomEE, not in applications. Right now the tomee-tck harness
works around it by pinning the JAXB RI through a
{{jakarta.xml.bind.JAXBContextFactory}} system property in the server JVM
({{runner-standalone/validation/src/tomee-conf/system.properties}}), since
{{JAXBContext}} reads this property before it asks ServiceLoader. Stock Plume,
shipped as is, has no such pin, so any application that relies on Bean
Validation XML config hits this failure the moment it runs on an unmodified
server. TomEE should set this pin itself, either in the Plume distribution's
default {{system.properties}} or in the BVal integration code, so applications
work without a manual JVM property.
h2. Steps to reproduce / TCK reference
Deploy the Jakarta Validation TCK ({{validation-tck-tests:3.1.1}}) against
stock TomEE 11 Plume, with no {{jakarta.xml.bind.JAXBContextFactory}} system
property set. Run the XML-configuration test paths — the tests that load
{{validation.xml}} and constraint-mapping XML descriptors. Each one fails
during JAXBContext creation because MOXy, not the JAXB RI, answers the
ServiceLoader lookup.
No TCK exclusion file lists these tests as excluded. The harness works around
the failure through a server JVM system property, set in
{{runner-standalone/validation/src/tomee-conf/system.properties}}, rather than
through {{runner-standalone/exclusions/validation.txt}}. With the pin in place,
the full validation TCK run (1,049 tests) passes with zero failures. Remove the
pin from {{system.properties}} and rerun the suite to reproduce the failure
directly, and to confirm the fix once TomEE pins the factory itself.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)