Skip to content

Changed code to use specific XPathFactoryImpl#192

Merged
pitbulk merged 1 commit intoSAML-Toolkits:masterfrom
dswitzer:patch-1
Oct 23, 2018
Merged

Changed code to use specific XPathFactoryImpl#192
pitbulk merged 1 commit intoSAML-Toolkits:masterfrom
dswitzer:patch-1

Conversation

@dswitzer
Copy link
Copy Markdown
Contributor

@dswitzer dswitzer commented Oct 3, 2018

This changes the XPathFactory call to use a specific XPathFactoryImpl to avoid issues where an environment may be using a default implementation that's incompatible with the code (such as using an outdated Saxon parser). This change attempts to use the default Java implementation, but if that is unavailable will fallback to try to load the default.

This will also help to ensure the XML is always parsed in a consistent manor, since everyone should be using the same XPathFactoryImpl.

This should resolve Issue #191.

This changes the XPathFactory call to use a specific XPathFactoryImpl to avoid issues where an environment may be using a default implementation that's incompatible with the code (such as using an outdated Saxon parser). This change attempts to use the default Java implementation, but if that is unavailable will fallback to try to load the default.

This will also help to ensure the XML is always parsed in a consistent manor, since everyone should be using the same XPathFactoryImpl.
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.1%) to 94.841% when pulling 2311853 on dswitzer:patch-1 into 54b2936 on onelogin:master.

@pitbulk pitbulk merged commit 8aed940 into SAML-Toolkits:master Oct 23, 2018
@siggemannen
Copy link
Copy Markdown

This change seem to have some side-effects when running OpenSaml under Karaf-container.
The call
factory = XPathFactory.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI, "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", java.lang.ClassLoader.getSystemClassLoader());

fails under JDK (1.8.101) with:

java.lang.IllegalAccessError: tried to access method javax.xml.xpath.XPathFactoryFinder.createInstance(Ljava/lang/String;)Ljavax/xml/xpath/XPathFactory; from class javax.xml.xpath.XPathFactory
at javax.xml.xpath.XPathFactory.newInstance(Unknown Source)

Likely due to weird classloading that Karaf likes to do.

I don't see a way to avoid it, short of patching the Util class or bumping JDK-version.
The following call works fine (and returns the same internal class com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl)

XPathFactory.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI);

Any workaround suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants