xml-apis.jar
More fussing with my least favorite XML-related Maven dependency.
Not for the first time, or even the second time, I spent the morning frustrated
by the xml-apis:xml-apis and xml-apis:xml-apis-ext packages in Maven. What
happened this morning was I tried to use newXMLGregorianCalendar("--06") on
(an instance of) the javax.xml.datatype.DatatypeFactory. It returned an object
with the string value “--06--” which was subsequently rejected by the API I
passed it to.
There was also a weird issue where newDefaultInstance() appeared to be
defined on DatatypeFactory in the IDE, but not in the compiler.
If you do a little spelunking around, you’ll eventually find XMLGregorianCalendarImpl.java
wherein, this comment:
// gMonth, --MM(z?),
// per XML Schema Errata, used to be --MM--(z?)
All evidence points to multiple instances of that class on the class path and one of them is old.
I went looking and discovered several instances lying around on the classpath, including one in xml-apis.
That’s gotta be at least 15 years old.
Over time, I’ve come to suspect that nothing in the xml-apis transitive
dependencies are actually needed any more. At least, not in the projects I work
on.
So I took them out:
configurations.all {
exclude(group="xml-apis", module="xml-apis")
exclude(group="xml-apis", module="xml-apis-ext")
}
Problem solved. And I think that’s going to be my go-to solution from now on until it causes something to break.