Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-264

XPathExpressionFactory should fallback to Jaxen if no JAXP 1.3 XPath implementation is available

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.5 M2, 1.0.4
    • Component/s: XML
    • Labels:
      None
    • Environment:
      Java 5 (build 1.5.0_13-b05-241) with standalone Xerces (2.9.2)

      Description

      When running with Java 5 without any JAXP 1.3 XPath implementation available but Jaxen present, XPathExpressionFactory fails to fallback to Jaxen.

      The following patch fixes the problem :

      — ../spring-ws-1.0.3/modules/xml/src/main/java/org/springframework/xml/xpath/XPathExpressionFactory.java 2007-12-21 16:26:18.000000000 +0100
      +++ XPathExpressionFactory.java 2008-01-08 18:12:38.000000000 +0100
      @@ -42,10 +42,14 @@

      private static final String JAXEN_CLASS_NAME = "org.jaxen.XPath";

      + private static boolean jaxpAvailable;
      private static boolean jaxenAvailable;

      static {
      // Check whether Jaxen is available
      + jaxpAvailable = (JaxpVersion.getJaxpVersion() >= JaxpVersion.JAXP_13);
      +
      + // Check whether Jaxen is available
      try {
      ClassUtils.forName(JAXEN_CLASS_NAME);
      jaxenAvailable = true;
      @@ -81,11 +85,27 @@
      public static XPathExpression createXPathExpression(String expression, Map namespaces)
      throws IllegalStateException, XPathParseException {
      Assert.hasLength(expression, "expression is empty");

      • if (JaxpVersion.getJaxpVersion() >= JaxpVersion.JAXP_13) {
      • logger.trace("Creating [javax.xml.xpath.XPathExpression]");
      • return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces);
        + if (jaxpAvailable) {
        + try { + logger.trace("Creating [javax.xml.xpath.XPathExpression]"); + return Jaxp13XPathExpressionFactory.createXPathExpression(expression, namespaces); + }

        + catch (XPathException e)

        { + throw e; + }

        + catch (Throwable e)

        Unknown macro: {+ // 'Cause we may get an ExceptionInInitializerError from JAXP+ // XPathFactory+ jaxpAvailable = false;++ if (!jaxenAvailable) { + throw new XPathParseException( + "Could not compile [" + expression + "] to a XPathExpression: " + e.getMessage(), e); + }+ // Else}

        }

      • else if (jaxenAvailable) {
        + if (jaxenAvailable) { logger.trace("Creating [org.jaxen.XPath]"); return JaxenXPathExpressionFactory.createXPathExpression(expression, namespaces); }

        Activity

        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Added patch as attachment.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Added patch as attachment.
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Fixed, thanks for the patch!

        Show
        arjen.poutsma Arjen Poutsma added a comment - Fixed, thanks for the patch!
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Reopening issues for 1.0.4

        Show
        arjen.poutsma Arjen Poutsma added a comment - Reopening issues for 1.0.4
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Backported to 1.0 branch.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Backported to 1.0 branch.
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing issues for 1.0.4

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing issues for 1.0.4

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            lbihanic Laurent Bihanic
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: