You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Jason Pell (JIRA)" <ji...@apache.org> on 2015/03/25 07:59:53 UTC

[jira] [Comment Edited] (CXF-6312) Unusable error message for Unmarshall Error

    [ https://issues.apache.org/jira/browse/CXF-6312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14379398#comment-14379398 ] 

Jason Pell edited comment on CXF-6312 at 3/25/15 6:59 AM:
----------------------------------------------------------

I added a sample of integrating the custom jaxb event handler here.

https://github.com/pellcorp/JavaFirst/blob/master/JavaFirst/src/test/java/com/pellcorp/jaxb/CustomEventHandlerTest.java

The test case creates two servers, one with the custom event handlers registered and one with out.  

I create two clients, one pointing at each server and submit a request that will fail validation.

My event handler adds "***" to content of the message, just as a test, and then I assert on this.

So it definately works just fine in 3.0.4 and 2.7.15.   There is no actual implementation of the validation in cxf, you have to implement your own and ensure you implement the new interfaces so that its correctly registered on the jaxb context and afterwards the appropriate after [un]marshalling method is called to produce the exception.

If you don't want to create a new one per chain (as I have done in my own project), you can implement your own.  Feel free to submit a PR via github if you want to contribute anything back.

If you think this feature can be better integrated, I will be more than happy to look at it.


was (Author: jpell):
I added a sample of integrating the custom schema validation here.

https://github.com/pellcorp/JavaFirst/blob/master/JavaFirst/src/test/java/com/pellcorp/jaxb/CustomEventHandlerTest.java

The test case creates two servers, one with the custom event handlers registered and one with out.  

I create two clients, one pointing at each server and submit a request that will fail validation.

My event handler adds "***" to content of the message, just as a test, and then I assert on this.

So it definately works just fine in 3.0.4 and 2.7.15.   There is no actual implementation of the validation in cxf, you have to implement your own and ensure you implement the new interfaces so that its correctly registered on the jaxb context and afterwards the appropriate after [un]marshalling method is called to produce the exception.

If you don't want to create a new one per chain (as I have done in my own project), you can implement your own.  Feel free to submit a PR via github if you want to contribute anything back.

If you think this feature can be better integrated, I will be more than happy to look at it.

> Unusable error message for Unmarshall Error
> -------------------------------------------
>
>                 Key: CXF-6312
>                 URL: https://issues.apache.org/jira/browse/CXF-6312
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 3.0.3, 3.0.4
>            Reporter: EasternWahoo
>            Assignee: Jason Pell
>            Priority: Critical
>
> CXF soap faults for unmarshalling errors do not contain information useful in locating the error.  For example, invalid content in an element  results in this faultString: Unmarshalling Error: xxxx .   (Where xxxx is the invalid data)
> The full stack trace contains messages with location of the bad string, i.e. : 
>  [com.sun.istack.SAXParseException2; lineNumber: 5; columnNumber: 38; xxxx].   This fragment in JAXBEncodeDecoder, extracts the message from the linked exception, i.e., the last exception in the stack: 
>        } catch (PrivilegedActionException e) { 
>             Exception ex = e.getException(); 
>             if (ex instanceof Fault) { 
>                 throw (Fault)ex; 
>             } 
>             if (ex instanceof javax.xml.bind.UnmarshalException) { 
>                 javax.xml.bind.UnmarshalException unmarshalEx = (javax.xml.bind.UnmarshalException)ex; 
>                 if (unmarshalEx.getLinkedException() != null) { 
>                     throw new Fault(new Message("UNMARSHAL_ERROR", LOG, 
>                                             unmarshalEx.getLinkedException().getMessage()), ex); 
> For more info, see this mailing list thread: http://cxf.547215.n5.nabble.com/Unmarshalling-error-content-usability-tt5755169.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)