Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonsXsdSchemaCollection / Apache Schema exceptions do not contain enough detail [SWS-409] #560

Closed
gregturn opened this issue Aug 5, 2008 · 3 comments
Assignees
Milestone

Comments

@gregturn
Copy link
Member

gregturn commented Aug 5, 2008

Pavel Tcholakov opened SWS-409 and commented

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.


Affects: 1.5.4

Attachments:

Referenced from: commits 3e11385

@gregturn
Copy link
Member Author

Tareq Abedrabbo commented

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.

@gregturn
Copy link
Member Author

Arjen Poutsma commented

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

@gregturn
Copy link
Member Author

gregturn commented May 4, 2012

Arjen Poutsma commented

Closing old issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants