I've tried following the discussion of returning collections as arrays but I have an instance where I have a JAXB element called Node and another element called AttributeMap.
Node class 'has' an AttributeMap
class Node {
public AttributeMap map;
}
I've used XmlIDRef and XmlID to map the AttributeMap.key to an attribute in the Node class. Basically, the attributeMap is passed as a distinct element outside of the xml for a Node.
I would like to return the Node and AttributeMap
So a method:
@GET @Path("{sk}")
@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
public Object [] getNodeBySk(@PathParam("sk") String sk) {
Node node = nodeRemote.getBySk(sk);
if (node == null)
throw new NotFoundException("Node not found for sk: " + sk);
NodeV1 nodeV1 = new NodeV1(node);
EntityAttributeMapV1 mapV1 = nodeV1.getEntityAttributeMap();
Object [] array = new Object [] {nodeV1, mapV1};
return array;
}
I get the dreaded
2009 2:48:17 PM com.sun.jersey.spi.container.ContainerResponse write
A message body writer for Java type, class [Ljava.lang.Object;, and MIME media type, application/xml, was not found
Is it possible to return a collection of heterogenous JAXB beans without creating a 'wrapper' class? The problem is that the way I have the JAXB annotations on the Node object, the attributeMap is not included. It is done this way intentionally because multiple Node entities can share the same attributeMap and I don't want to marshall the same attribute map multiple times inside each Node that shares it.
-mark
_______________________________________________
Mark A. Rabick
Software Engineer
Northrop Grumman - Integrated Mission Systems (IS/DSD/IMS)
3200 Samson Way
Bellevue, NE 68123
Ph: (402) 293-7091
Em: mark.rabick_at_ngc.com
Remember PFC Ross A. McGinnis...
http://www.army.mil/medalofhonor/McGinnis/index.html
... MA2 Michael A. Monsoor, Lt. Michael P. Murphy, Cpl. Jason Dunham, SFC Paul Ray Smith and the rest...
http://www.cmohs.org/recipients/most_recent.htm