Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with Issues fetching the XPathFactory on later versions of Java #1453

Open
michaelwiles opened this issue Feb 7, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@michaelwiles
Copy link

Firstly, apologies if this is the wrong forum for this discussion. This is not really a question that works for stack overflow.

I'm getting the following error:

Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/dom with the XPathFactoryConfigurationException: java.util.ServiceConfigurationError: javax.xml.xpath.XPathFactory: jar:file:/home/michael/.m2/repository/net/sf/saxon/saxon/9.3/saxon-9.3.jar!/META-INF/services/javax.xml.xpath.XPathFactory:2: Illegal configuration-file syntax [in thread "main"]
at java.xml/javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:119)
at org.springframework.xml.xpath.Jaxp13XPathExpressionFactory.(Jaxp13XPathExpressionFactory.java:44)
at org.springframework.xml.xpath.XPathExpressionFactory.createXPathExpression(XPathExpressionFactory.java:72)

Some googling let me here and here.

And has to do with the version of saxon in use and newer versions of java.

So this is the line of code in Jaxp13XPathExpressionFactory referenced in the stack trace:

private static XPathFactory xpathFactory = XPathFactory.newInstance();

It seems there are two ways to address this problem:

  1. Use a different implementation of Saxon
  2. Change the way this XMlFactory is instantiated

I'm wondering if the latter approach is a possiblity in the spring context. It would mean somehow providing a way to customise this instantiation... or better still, maybe we can inject the factory?

I'm just raising this as I want to see whether I can avoid changing the version of saxon that is in use.

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants