JAXB XMLAdapter method does not throws Exception

前端 未结 1 2037
悲哀的现实
悲哀的现实 2021-01-01 16:12

I am using JAXB XMLadapter to marshal and unmarshal Boolean values. The application\'s XML file will be accessed by C# application also. We have to validate this XML file an

相关标签:
1条回答
  • 2021-01-01 16:25

    From the JavaDoc of XMLAdapter#unmarshal(ValueType):

    Throws: java.lang.Exception - if there's an error during the conversion. The caller is responsible for reporting the error to the user through ValidationEventHandler.

    So, yes - the exception is eaten and then reported using ValidationEventHandler, not thrown to the top of your stack.

    Check if you are already using any (custom, perhaps) ValidationEventHandler that groups your exceptions, or use DefaultValidationEventHandler, like this:

    unmarshaller.setEventHandler(new DefaultValidationEventHandler());
    

    It will cause unmarshalling failure on first error.

    0 讨论(0)
提交回复
热议问题