aspose file tools*
The moose likes Web Services and the fly likes JAXB Custom Validation Handler is not receiving control during Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAXB Custom Validation Handler is not receiving control during Exception" Watch "JAXB Custom Validation Handler is not receiving control during Exception" New topic
Author

JAXB Custom Validation Handler is not receiving control during Exception

M Sud
Greenhorn

Joined: Oct 25, 2010
Posts: 2
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

Joined: Oct 25, 2010
Posts: 2
Hi
Can anyone help me with this?

Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1164
M Sud,

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

Regards,
Dan

William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!


My free books and tutorials: http://www.slideshare.net/krizsan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB Custom Validation Handler is not receiving control during Exception
 
Similar Threads
Is Backing bean Required
Trigger handleFault method in jax-rpc message handler
Custom Validator
View model ignores custom validation for Double values
Order of Execution? Tag Handler or ManagedBean