users@jaxb.java.net

JAXB Swallowing Exceptions

From: Tim Canavan <tim.canavan_at_googlemail.com>
Date: Wed, 23 May 2012 09:47:05 +0200

JAXB 2.0 swallows Number format exceptions because it regards them as
recoverable.

We tried using our Factory using @UsesJAXBContext to try and override the
createUnmarshaller and
set the EventHandler of the Unmarshaller to the DefaultValidationHandler
but found that this was not possible

as JAXBContextImpl the default is also used in the bridge code.

We are bootstrapping jaxws using

<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>

There is no way to configure the level of severity of the validation you
would like.

JAXB reports an error only in the case of FATAL errors. This is clearly
wrong as it allows
invalid data to enter the system.


// from UnmarshallerContext// calls Unmarshaller getEventHandler.
 ValidationEventHandler eventHandler = parent.getEventHandler();

        boolean recover = eventHandler.handleEvent(event); // JAXB
handles event only if is fatal // it considers ERRORS as
recoverable !!!

        // if the handler says "abort", we will not return the object
      // from the unmarshaller.getResult() if(!recover)
aborted = true;

        if( !canRecover || !recover )
            throw new SAXParseException2( event.getMessage(), locator,
                new UnmarshalException(
                    event.getMessage(),
                    event.getLinkedException() ) );


The same problem is discussed here.

http://old.nabble.com/Setting-marshaller-properties-with-JAX-WS-td29340141.html