You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by yoannch <yo...@gmail.com> on 2011/06/28 18:25:24 UTC

Problem with CXF / Jaxb with heterogeonous lists

Hi there, I'm new to CXF and JAXB. I've faced some issues such as using lists
of objects in my model objects.
I'm building a RESTful webservice and use an object called WebServiceResult
as a "Wrapper" for handling my response.
My class looks like this


@XmlRootElement
public class WebServiceResult {
	
	private Boolean success = new Boolean(false);
	
	@XmlAnyElement @XmlMixed
	private List < Object > result;
	
	private Integer size = new Integer(0);
        ...
}

getters and setters removed. I use a List to store my results, whatever are
their types.

I've tried using it putting a Sic object described below

@XmlRootElement
public class Sic {
	
	private Integer id;
	
	private String code;
	
	private String label;
        ...
}

in the list, but when I call my service like below

@GET
public WebServiceResult testGet(){

	WebServiceResult res = new WebServiceResult();
	res.setSuccess(true);
	res.setSize(42);

	ArrayList l = new ArrayList();

	Sic s = new Sic();
	s.setCode("TESTCODE");

	l.add(s);

	res.setResult(l);

	return res;
}
, I get a 

JAXBException occurred : 1 counts of IllegalAnnotationExceptions

Did I miss something?? I've read the 
http://jaxb.java.net/tutorial/section_2_2_12_6-Content-A-Mixed-List-of-Elements.html
following documentation about JAXB  but I couldn't make it work. I've
understood that it's a matter of "class interpretation" but I couldn't solve
it.

I realy don't know what to do, I'm a JAX and CXF newbie.

--
View this message in context: http://cxf.547215.n5.nabble.com/Problem-with-CXF-Jaxb-with-heterogeonous-lists-tp4532374p4532374.html
Sent from the cxf-issues mailing list archive at Nabble.com.