DaisyDiff triggers a NoClassDefFound in JVM 8

I need the class XML11Char provided by the JVM, and Confluence wasn’t configured to provide it.

Using Confluence 7.4.0 launched by Maven (hence running on AdoptOpenJDK 8, I’ve checked), I’m trying to run DaisyDiff, the library provided by Atlassian in Confluence, to diff two excerpts of HTML.

Unfortunately, it performs a static call to com.sun.org.apache.xml.internal.utils.XML11Char.isXML11ValidNCName() and fails with a NoClassDefFoundError.

It is because this class is supposed to be provided by the JVM 8, it is in the rt.jar, but Confluence doesn’t import it.

Has anyone solved this issue? Has anyone had to use another parser to create diffs?

Here is the stacktrace:

java.lang.NoClassDefFoundError: com/sun/org/apache/xml/internal/utils/XML11Char
	at org.outerj.daisy.diff.helper.CleanBrokenAttributeQNamesHandler.filterBrokenQNameAttributes(CleanBrokenAttributeQNamesHandler.java:87)
	at org.outerj.daisy.diff.helper.CleanBrokenAttributeQNamesHandler.startElement(CleanBrokenAttributeQNamesHandler.java:80)
	at org.outerj.daisy.diff.helper.MergeCharacterEventsHandler.startElement(MergeCharacterEventsHandler.java:107)
	at org.outerj.daisy.diff.helper.NekoHtmlParser$RemoveNamespacesHandler.startElement(NekoHtmlParser.java:133)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.cyberneko.html.HTMLTagBalancer.callStartElement(HTMLTagBalancer.java:1164)
	at org.cyberneko.html.HTMLTagBalancer.startElement(HTMLTagBalancer.java:754)
	at org.cyberneko.html.filters.DefaultFilter.startElement(DefaultFilter.java:136)
	at org.cyberneko.html.filters.NamespaceBinder.startElement(NamespaceBinder.java:279)
	at org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(HTMLScanner.java:2760)
	at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2110)
	at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:920)
	at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
	at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.outerj.daisy.diff.helper.NekoHtmlParser.parse(NekoHtmlParser.java:68)
	at org.outerj.daisy.diff.HtmlCleaner.cleanAndParse(HtmlCleaner.java:41)
	at com.playsql.requirementyogi.reporting.diff.DiffEngine.getDiffHtml(DiffEngine.java:90)

Hi @aragot,

While I do not have a clean solution for your problem at hand, I may have a suggestion for an ugly workaround:

This sounds like something you could potentially solve with the maven-shade-plugin. The idea is that you create a shaded dependency and change the package of com.sun.org.apache.xml.internal.utils.XML11Char to something like com.playsql.shaded.XML11Char and provide your own implementation that way. We have had to solve a similar problem this way in the past and so far it has worked fine.

However, there probably is a much better and cleaner solution, so I would definitely consider this a last resort.

Cheers,
Sven