so…

xml-apis.jar

Volume 10, Issue 33; 20 Nov 2026

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.

#Java #XML

Please provide your name and email address. Your email address will not be displayed and I won’t spam you, I promise. Your name and a link to your web address, if you provide one, will be displayed.

Your name:

Your email:

Homepage:

Do you comprehend the words on this page? (Please demonstrate that you aren't a mindless, screen-scraping robot.)

What is eight times two?   (e.g. six plus two is 8)

Enter your comment in the box below. You may style your comment with the CommonMark flavor of Markdown.

All comments are moderated. I don’t promise to preserve all of your formatting and I reserve the right to remove comments for any reason.