Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB Custom Validation Handler is not receiving control during Exception

 
M Sud
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am getting NumberFormatException during JAXB Unmarshal. The exception does not provide line number or the field which is having the incorrect value. I tried to create my own validation handler. But when the exception happens, the control is not coming into my custom validation handler. I am using JAXB 2.0.
By manual verification, I later found that this is happening due to an attribute of a field having wrong data. The attribute is a BigDecimal and value came in was empty (""), which trigggered the exception.

Why does the JAXB not reaching my custom validation handler during an exception? Are there any other ways are there for me to find out the field / attribute which has caused the exception?

Sudeep
 
M Sud
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can anyone help me with this?

 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
M Sud,

I would try using a tool such as XML Schema Validator .

Regards,
Dan
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
In order for JAXB to perform validation against a XML schema, the Marshaller or Unmarshaller has to be configured with the schema to validate against.
Example:

I don't know how to accomplish this with generated stubs, though.

If you manage to obtain the XML fragment sent with the request, you can validate it against the XML schema using the Eclipse IDE.
Best wishes!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic