- an exception javax.jcr.nodetype.ConstraintViolationException is thrown but its message says that the property definition cannot be found "Cannot find a definition for the property named 'org:gender' on the node at ..." instead of which constraint is violated
When ModeShape does not find an appropriate property definition, it doesn't really try to figure out if there is one with the same name but an incompatible type or constraint. It's not always easy to figure out what property definition "should apply", but in this case we should figure it out and report a more useful message. Feel free to log an enhancement request.
- this exception is caught then by org.modeshape.jcr.JcrContentHandler.BasicNodeHandler.create() and encapsulated into org.modeshape.jcr.JcrContentHandler.EnclosingSAXException
The JCR client has to catch EnclosingSAXException and then extract the cause (javax.jcr.nodetype.ConstraintViolationException) whose message is not very helpful.
I understand that org.modeshape.jcr.JcrContentHandler extends SAX' DefaultHandler but anyway it would be useful for a JCR client to know the real cause.
Doesn't it make sense to change this exception handling?
Yes, that's definitely not very useful. We should be unwrapping it. Please log a separate issue for this.
You're welcome, Randall.
Can you provide a code sample of how you're importing, and a stack trace of the exception? If you're using Session.importXML(...), then our implementation should already be unwrapping the EnclosingSAXException and throwing the wrapped ConstraintViolationException, VersionException, or ItemExistsException. (It may be possible we're doubly-wrapping an exception, in which case we'll only unwrap once. But I doubt this is the case.)
I've added test cases that use Session.importXML to import XML files that contain values that will violate constraints, and with both system and document views I get a ConstraintViolationException upon import.
Note that if you're using the ContentHandler returned by Session.getImportContentHandler(), then you should get a SAXException, as the ConstraintViolationExceptions are not on the ContentHandler method signatures.
I've marked MODE-1139 as 'Cannot Reproduce Bug'. Feel free to reopen the issue if you can provide more information.