Skip to content

Possible classpath scanning issues by using XPathFactory.newInstance() #86

@dfranssen

Description

@dfranssen

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions