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

CommonsXsdSchemaCollection / Apache Schema exceptions do not contain enough detail

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.4
    • Fix Version/s: 1.5.5
    • Component/s: XML
    • Labels:
      None
    • Environment:
      Spring 2.5.5, Spring WS 1.5.4, Apache XML Schema 1.4.2, Java 1.5, JBoss 4.2.2GA, Windows XP

      Description

      An <xsd:import/> instruction for an invalid file name causes the following exception on context initialization:

      org.apache.ws.commons.schema.XmlSchemaException
      at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:351)
      at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1839)
      at org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1615)
      at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:181)
      at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:83)
      at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:424)
      at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:347)
      at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:379)
      at org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.afterPropertiesSet(CommonsXsdSchemaCollection.java:133)

      The root cause is a file not found exception, but it's not at all obvious which XSD caused this, nor what file is missing. (In my case there was a typo in a the import instruction so it was quite hard to spot by just examining the schema files.) I think it's mostly org.apache.ws.commons.schema.XmlSchemaException to blame for not correctly displaying the root cause, but it would be even nicer if CommonsXsdSchemaCollection would trap the exception, report explicitly which XSD resource caused it and re-throw it as a CommonsXsdSchemaException.

        Activity

        pcholakov Pavel Tcholakov created issue -
        arjen.poutsma Arjen Poutsma made changes -
        Field Original Value New Value
        Fix Version/s 1.5.5 [ 11067 ]
        arjen.poutsma Arjen Poutsma made changes -
        Original Estimate 0.5d [ 14400 ]
        Remaining Estimate 0.5d [ 14400 ]
        Hide
        tareq Tareq Abedrabbo added a comment -

        It seems that org.apache.ws.commons.schema.XmlSchemaException is not the only exception to be thrown in case of error in the xsd. For instance, org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema wraps every exception with a RuntimeException. In some other cases a NPE is thrown.
        Thus the simplest and safest option seems to me to surround Commons Xsd code with a try/catch(Exception).
        patch+unit test.

        Show
        tareq Tareq Abedrabbo added a comment - It seems that org.apache.ws.commons.schema.XmlSchemaException is not the only exception to be thrown in case of error in the xsd. For instance, org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema wraps every exception with a RuntimeException. In some other cases a NPE is thrown. Thus the simplest and safest option seems to me to surround Commons Xsd code with a try/catch(Exception). patch+unit test.
        tareq Tareq Abedrabbo made changes -
        Attachment SWS-409.patch [ 14596 ]
        arjen.poutsma Arjen Poutsma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Fixed, thanks for spotting this, and for the patch!\

        Show
        arjen.poutsma Arjen Poutsma added a comment - Fixed, thanks for spotting this, and for the patch!\
        arjen.poutsma Arjen Poutsma made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        arjen.poutsma Arjen Poutsma added a comment -

        Closing old issues

        Show
        arjen.poutsma Arjen Poutsma added a comment - Closing old issues
        arjen.poutsma Arjen Poutsma made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        23d 7h 6m 1 Arjen Poutsma 28/Aug/08 9:30 AM
        In Progress In Progress Resolved Resolved
        4m 13s 1 Arjen Poutsma 28/Aug/08 9:34 AM
        Resolved Resolved Closed Closed
        1344d 21h 29m 1 Arjen Poutsma 04/May/12 7:03 AM

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            pcholakov Pavel Tcholakov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: