castor-data-binding / castor

http://castor-data-binding.github.io/castor/
35 stars 29 forks source link

Validation of references fails with lists #78

Open pfhartma opened 5 years ago

pfhartma commented 5 years ago

During unmarshalling, Castor throws a validation error concerning unresolved id reference. This seems to be a false positive, as everything looks fine with lenient id validation enabled.

I've created a minimal example to demonstrate the issue:

example.zip

The problem seems to be, that the referenced object is located inside a list. The validator does not step into the list element and does not register the referenced object.


Castor Version: 1.4.1 Stack trace:

Exception in thread "main" org.exolab.castor.xml.MarshalException: ValidationException: ClassDescriptorResolver from context must not be null!{File: [not available]; line: 14; column: 12}
    at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:832)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:703)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:589)
    at de.CastorValidateTest.main(CastorValidateTest.java:96)
Caused by: ValidationException: ClassDescriptorResolver from context must not be null!
    at org.exolab.castor.xml.Validator.checkUnresolvedIdrefs(Validator.java:185)
    at org.exolab.castor.xml.EndElementProcessor.compute(EndElementProcessor.java:377)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:473)