• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAXB Custom Validation Handler is not receiving control during Exception

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Can anyone help me with this?

 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
M Sud,

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

Regards,
Dan
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic