cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Freeman Fang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-4502) An Exception cannot be marshalled if contains a field of type java.util.Set
Date Mon, 17 Sep 2012 02:49:07 GMT

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

Freeman Fang commented on CXF-4502:
-----------------------------------

Hi,

Jaxb only support List as collections, so use List instead.
Or you can use XmlAdapter to adapter the data type during marshal/unmarshal, take a look at
java_first_jaxws example shipped with kit, where we demonstrate how to use XmlAdapter.

Freeman
                
> An Exception cannot be marshalled if contains a field of type java.util.Set 
> ----------------------------------------------------------------------------
>
>                 Key: CXF-4502
>                 URL: https://issues.apache.org/jira/browse/CXF-4502
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime, JAXB Databinding
>    Affects Versions: 2.6.1
>            Reporter: Peter Szanto
>            Priority: Critical
>
> If I have an Exception that has a java.util.Set field like this :
> {code}
> public class MissingReferenceException extends Exception {
> 	
> 	private Set<Integer> references; 
> 	
> 	private static final long serialVersionUID = -5294298476513084387L;
> 	public MissingReferenceException() {
> 	}
> 	
> 	public MissingReferenceException(Set<Integer> references) {
> 		this.setReferences(references);
> 	}
> 	public Set<Integer> getReferences() {
> 		return references;
> 	}
> 	public void setReferences(Set<Integer> references) {
> 		this.references = references;
> 	}
> }
> {code}
> then when I throw it I get the below exception :
> Caused by: java.lang.IllegalArgumentException: Argument is not an array
> 	at java.lang.reflect.Array.getLength(Native Method)
> 	at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeArrayObject(JAXBEncoderDecoder.java:423)
> 	at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshallException(JAXBEncoderDecoder.java:389)
> Looking at the source of JAXBEncoderDecoder.writeArrayObject() it is quite obvious that
List is explicitly handled, but instead it should be Collection handled to cover all other
suclasses like Set, Vector etc...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message