dxa-web-application-java icon indicating copy to clipboard operation
dxa-web-application-java copied to clipboard

Possible classpath scanning issues by using XPathFactory.newInstance()

Open dfranssen opened this issue 8 years ago • 0 comments

In pre 2.0 releases the dxa-tridion-provider is using XPathFactory.newInstance() in the XPathResolver enum to create an XPathExpression.

By using that XPathFactory.newInstance() a suitabable factory implementation will be found by scanning the classpath (cfr javadoc). This means that the classloading order could be different between restarts of Tomcat. Documentation of Tomcat 8 states that the order of loading is not anymore by alphabetical order as in previous versions but by order of which classes are requested first. This could lead to nullpointer exceptions when e.g. jstl-1.2.jar is on the classpath and has been loaded first. This is due to org.apache.taglibs.standard.tag.common.xml.JSTLXPathFactory being used as factory for which xpath.compile(sourceString) will always return null.

Furthermore the usage of ThreadLocal seems overhead as recreating the XPathExpression each time has no performance impact.

dfranssen avatar Dec 08 '17 08:12 dfranssen