Commit 65d794c
committed
Merge branch 'xml-woes'
This topic branch adds a rather ugly, but required, work-around when
3rd-party libraries provide XML components that can easily lead to
class path problems when processing XML data via XPath. The symptom
is invariable an exception with a trace like this one:
> java.lang.NoSuchMethodError: org.apache.xpath.XPathContext.<init>(Z)V
> at org.apache.xpath.jaxp.XPathImpl.eval(XPathImpl.java:207)
> at org.apache.xpath.jaxp.XPathImpl.evaluate(XPathImpl.java:281)
> at org.apache.xpath.jaxp.XPathImpl.evaluate(XPathImpl.java:371)
> at org.scijava.util.XML.<init>(XML.java:141)
> [...]
Such errors are caused by whatever implementation of the XPathFactory
finds to be claiming the DocumentBuilderFactoryImpl service in the
corresponding META-INF/services/.
For example, the Batik component in Fiji ships a part of xalan (which is
actually not needed for Java 1.6 and later, because Xalan is now bundled
with Java), and likewise does OMERO insight ship xalan, but an
*incompatible* version of it.
As a work-around, we use the fact that the XPathFactory asks the current
thread's context class loader to discover the services. If it discovers
a non-functional XPath implementation, we set the context class loader
to the parent class loader until we find a working XPath implementation.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 file changed
+48
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
116 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
117 | 164 | | |
118 | 165 | | |
119 | 166 | | |
| |||
0 commit comments