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

org.springframework.xml.sax.SaxUtils swallows exceptions

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.4
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Windows/Spring 3.0.6.RELEASE/Websphere Application Server 7.0.0.15

      Description

      While starting a spring-ws application on Websphere, CommonsXsdSchemaCollection makes a call to SaxUtils in order to resolve the location of XSDs defined in the collection. I hit a problem whereby the SaxUtils.getSystemId() swallows an exception (see below) because there is a space in the URL of the XSD. This was a serious pain to track down because the code went on to create a different exception that lead me on a wild goose chase. Would be good if the exception was logged.

      ====================== Note: I've X'd out some of the file names
      [1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - resource -class path resource [xsd/XXXXXXXXXXXService_V_1_0.xsd]
      [1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - resource URL -wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-xx-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
      [1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - resource URL external form-wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
      [1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - URISyntaxException -
      java.net.URISyntaxException: Illegal character in opaque part at index 113: wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
      	at java.net.URI$Parser.fail(URI.java:2820)
      	at java.net.URI$Parser.checkChars(URI.java:2993)
      	at java.net.URI$Parser.parse(URI.java:3030)
      	at java.net.URI.<init>(URI.java:589)
      	at org.springframework.xml.sax.SaxUtils.getSystemId(SaxUtils.java:61)
      =================================

      I modified SaxUtils to produce the logging info above (this is not a suggested solution, just some verbose logging I added to try find out what was happening). Below is the modified code that produced the log output above...

          /** Retrieves the URL from the given resource as System ID. Returns <code>null</code> if it cannot be opened. */
          public static String getSystemId(Resource resource) {
              try {
              	logger.info("resource URL -" + resource.getURL());
              	logger.info("resource URL external form-" + resource.getURL().toExternalForm());
                  return new URI(resource.getURL().toExternalForm()).toString();
              }
              catch (IOException e) {
              	logger.info("IOException -",e);
                  return null;
              }
              catch (URISyntaxException e) {
              	logger.info("URISyntaxException -",e);
                  return null;
              }
          }

        Activity

        davidnee David Nee created issue -
        arjen.poutsma Arjen Poutsma made changes -
        Field Original Value New Value
        Description While starting a spring-ws application on Websphere, CommonsXsdSchemaCollection makes a call to SaxUtils in order to resolve the location of XSDs defined in the collection. I hit a problem whereby the SaxUtils.getSystemId() swallows an exception (see below) because there is a space in the URL of the XSD. This was a serious pain to track down because the code went on to create a different exception that lead me on a wild goose chase. Would be good if the exception was logged.


        ====================== Note: I've X'd out some of the file names
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - resource -class path resource [xsd/XXXXXXXXXXXService_V_1_0.xsd]
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - resource URL -wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-xx-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - resource URL external form-wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - URISyntaxException -
        java.net.URISyntaxException: Illegal character in opaque part at index 113: wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
        at java.net.URI$Parser.fail(URI.java:2820)
        at java.net.URI$Parser.checkChars(URI.java:2993)
        at java.net.URI$Parser.parse(URI.java:3030)
        at java.net.URI.<init>(URI.java:589)
        at org.springframework.xml.sax.SaxUtils.getSystemId(SaxUtils.java:61)
        =================================

        I modified SaxUtils to produce the logging info above (this is not a suggested solution, just some verbose logging I added to try find out what was happening). Below is the modified code that produced the log output above...

            /** Retrieves the URL from the given resource as System ID. Returns <code>null</code> if it cannot be opened. */
            public static String getSystemId(Resource resource) {
                try {
                 logger.info("resource URL -" + resource.getURL());
                 logger.info("resource URL external form-" + resource.getURL().toExternalForm());
                    return new URI(resource.getURL().toExternalForm()).toString();
                }
                catch (IOException e) {
                 logger.info("IOException -",e);
                    return null;
                }
                catch (URISyntaxException e) {
                 logger.info("URISyntaxException -",e);
                    return null;
                }
            }
        While starting a spring-ws application on Websphere, CommonsXsdSchemaCollection makes a call to SaxUtils in order to resolve the location of XSDs defined in the collection. I hit a problem whereby the SaxUtils.getSystemId() swallows an exception (see below) because there is a space in the URL of the XSD. This was a serious pain to track down because the code went on to create a different exception that lead me on a wild goose chase. Would be good if the exception was logged.

        {noformat}
        ====================== Note: I've X'd out some of the file names
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - resource -class path resource [xsd/XXXXXXXXXXXService_V_1_0.xsd]
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - resource URL -wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-xx-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - resource URL external form-wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
        [1/18/12 13:47:15:228 CST] 00000017 SystemOut O 2012-01-18 13:47:15,228 INFO SaxUtils - URISyntaxException -
        java.net.URISyntaxException: Illegal character in opaque part at index 113: wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
        at java.net.URI$Parser.fail(URI.java:2820)
        at java.net.URI$Parser.checkChars(URI.java:2993)
        at java.net.URI$Parser.parse(URI.java:3030)
        at java.net.URI.<init>(URI.java:589)
        at org.springframework.xml.sax.SaxUtils.getSystemId(SaxUtils.java:61)
        =================================
        {noformat}

        I modified SaxUtils to produce the logging info above (this is not a suggested solution, just some verbose logging I added to try find out what was happening). Below is the modified code that produced the log output above...

        {code}
            /** Retrieves the URL from the given resource as System ID. Returns <code>null</code> if it cannot be opened. */
            public static String getSystemId(Resource resource) {
                try {
                 logger.info("resource URL -" + resource.getURL());
                 logger.info("resource URL external form-" + resource.getURL().toExternalForm());
                    return new URI(resource.getURL().toExternalForm()).toString();
                }
                catch (IOException e) {
                 logger.info("IOException -",e);
                    return null;
                }
                catch (URISyntaxException e) {
                 logger.info("URISyntaxException -",e);
                    return null;
                }
            }
        {code}
        Fix Version/s 2.0.4 [ 12628 ]
        Assignee Arjen Poutsma [ arjen.poutsma ]
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        arjen.poutsma Arjen Poutsma made changes -
        Time Spent 0.05h [ 180 ]
        Worklog Id 28552 [ 28552 ]
        arjen.poutsma Arjen Poutsma made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        arjen.poutsma Arjen Poutsma made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            davidnee David Nee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - Not Specified
              Not Specified
              Logged:
              Time Spent - 0.05h
              0.05h