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

Windows-specific error with relative XSD referencing

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.5
    • Fix Version/s: 2.1.1
    • Component/s: Core
    • Labels:
      None
    • Environment:
      OS Windows

      Description

      It appears, that Spring ignores relative addressing in XSD files on Windows platform.

      Root cause was found at org.springframework.xml.sax.SaxUtils.getSystemId() method. It tries to construct java.net.URI object from path string with Windows-style -slashes and fails on this operation. This path string is obtained from java.net.URL.toExternalForm(). Exception is silently ignored and null is returned from the method.

      Current workaround is to implement custom org.springframework.core.io.ClassPathResource class that will override getURL() returning paths with valid /-slashes.
      Then one should use instances of this class to populate xsds property of org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection, instead of automatic Spring-generated instances.
      Patch with workaround is attached. Now XSD schema collection declaration looks like this:

      <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
        <property name="xsds">
          <list>
            <bean class="com.platform.util.spring.SafeClassPathResource">
               <constructor-arg value="META-INF/xsd/service.xsd" />
            </bean>
          </list>
        </property>
      </bean>

      1. SafeClassPathResource.patch
        2 kB
        Maxim Myslivtssev

        Activity

        desliner Maxim Myslivtssev created issue -
        arjen.poutsma Arjen Poutsma made changes -
        Field Original Value New Value
        Assignee Arjen Poutsma [ arjen.poutsma ]
        Fix Version/s 2.1.1 [ 13012 ]
        Description It appears, that Spring ignores relative addressing in XSD files on Windows platform.

        Root cause was found at org.springframework.xml.sax.SaxUtils.getSystemId() method. It tries to construct java.net.URI object from path string with Windows-style \-slashes and fails on this operation. This path string is obtained from java.net.URL.toExternalForm(). Exception is silently ignored and null is returned from the method.

        Current workaround is to implement custom org.springframework.core.io.ClassPathResource class that will override getURL() returning paths with valid /-slashes.
        Then one should use instances of this class to populate xsds property of org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection, instead of automatic Spring-generated instances.
        Patch with workaround is attached. Now XSD schema collection declaration looks like this:

        <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
          <property name="xsds">
            <list>
              <bean class="com.platform.util.spring.SafeClassPathResource">
                 <constructor-arg value="META-INF/xsd/service.xsd" />
              </bean>
            </list>
          </property>
        </bean>
        It appears, that Spring ignores relative addressing in XSD files on Windows platform.

        Root cause was found at org.springframework.xml.sax.SaxUtils.getSystemId() method. It tries to construct java.net.URI object from path string with Windows-style \-slashes and fails on this operation. This path string is obtained from java.net.URL.toExternalForm(). Exception is silently ignored and null is returned from the method.

        Current workaround is to implement custom org.springframework.core.io.ClassPathResource class that will override getURL() returning paths with valid /-slashes.
        Then one should use instances of this class to populate xsds property of org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection, instead of automatic Spring-generated instances.
        Patch with workaround is attached. Now XSD schema collection declaration looks like this:

        {code:xml}
        <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
          <property name="xsds">
            <list>
              <bean class="com.platform.util.spring.SafeClassPathResource">
                 <constructor-arg value="META-INF/xsd/service.xsd" />
              </bean>
            </list>
          </property>
        </bean>
        {code}
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        I suspect Spring-WS is not to blame, but rather Spring itself. But I've tried to reproduce this on a Windows VM, and I couldn't. I've attached a sample maven project, could you please take a look at it and see what's different from your project?

        Show
        arjen.poutsma Arjen Poutsma added a comment - I suspect Spring-WS is not to blame, but rather Spring itself. But I've tried to reproduce this on a Windows VM, and I couldn't. I've attached a sample maven project, could you please take a look at it and see what's different from your project?
        arjen.poutsma Arjen Poutsma made changes -
        Attachment path-1.0-src.zip [ 19996 ]
        arjen.poutsma Arjen Poutsma logged work - 26/Jun/12 2:38 AM
        • Time Spent:
          0.2d
           
          <No comment>
        arjen.poutsma Arjen Poutsma made changes -
        Time Spent 0.2d [ 5760 ]
        Worklog Id 29014 [ 29014 ]
        arjen.poutsma Arjen Poutsma made changes -
        Status In Progress [ 3 ] Open [ 1 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing as Cannot Reproduce for now, due to lack of feedback.

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing as Cannot Reproduce for now, due to lack of feedback.
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Cannot Reproduce [ 5 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        35d 20h 1m 1 Arjen Poutsma 26/Jun/12 1:02 AM
        In Progress In Progress Open Open
        1h 36m 1 Arjen Poutsma 26/Jun/12 2:38 AM
        Open Open Resolved Resolved
        48d 23h 26m 1 Arjen Poutsma 14/Aug/12 2:04 AM

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            desliner Maxim Myslivtssev
          • Votes:
            0 Vote for this issue
            Watchers:
            1 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.2d
              0.2d