Hello,
I have googled these issues before coming to tihs forum. I have seen a
couple of related posts on this forum but didn't see how they were resolved.
Here is the simple test code I have:
Locations.java
--------------
@XmlRootElement(name = "Locations")
public class Locations
{
private List<Location> locations;
public void setLocations(final List<Location> locations)
{
this.locations = locations;
}
public List<Location> getLocations()
{
return locations;
}
}
Location.java
-------------
@XmlRootElement(name = "Location")
public class Location
{
private String id;
public Location(String id)
{
this.id = id;
}
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
}
LocationServices.java
---------------------
@Path("/locationservices/")
public class LocationServices
{
private static final Logger log = LogManager
.getLogger(LocationManagerServiceImpl.class);
@POST
@Path("/pilot/{id}")
public Response updatePilotLocations(@PathParam("id") String id,
Locations locations)
{
Long appId = Long.parseLong(id);
log.debug("Received appid = " + appId);
if (locations == null || locations.getLocations() == null)
{
log.warn("Received empty location list.");
return Response.notModified().build();
}
for (Location loc : locations.getLocations())
{
log.debug("Received loc = " + loc.getId());
}
return Response.ok(locations).build();
}
@GET
@Path("/pilot/{id}")
public String getPilotLocation(@PathParam("id") String id)
{
log.debug("Received id = " + id);
return "OK";
}
@GET
@Path("/pilot/")
public Locations getPilotLocations()
{
log.debug("In getPilotLocations");
Locations locs = new Locations();
List<Location> l = new ArrayList<Location>();
l.add(new Location("1"));
l.add(new Location("2"));
locs.setLocations(l);
return locs;
}
}
I am seeing 2 issues related to Collection/List:
Issue #1
======
In getPilotLocations(), it is giving:
2009-07-23 17:09:49,387 INFO [STDOUT] (TP-Processor3) 7145811
[TP-Processor3] DEBUG com.apps.service.rest.LocationServices - In
getPilotLocations
2009-07-23 17:09:49,484 ERROR [STDERR] (TP-Processor3) Jul 23, 2009 5:09:49
PM org.apache.cxf.jaxrs.provider.AbstractJAXBProvider handleJAXBException
WARNING: JAXBException occurred : 1 counts of IllegalAnnotationExceptions
2009-07-23 17:09:49,485 INFO [STDOUT] (TP-Processor3) 7145909
[TP-Processor3] ERROR STDERR - Jul 23, 2009 5:09:49 PM
org.apache.cxf.jaxrs.provider.AbstractJAXBProvider handleJAXBException
WARNING: JAXBException occurred : 1 counts of IllegalAnnotationExceptions
2009-07-23 17:09:49,493 ERROR [STDERR] (TP-Processor3) Jul 23, 2009 5:09:49
PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : 1 counts of
IllegalAnnotationExceptions
2009-07-23 17:09:49,494 INFO [STDOUT] (TP-Processor3) 7145918
[TP-Processor3] ERROR STDERR - Jul 23, 2009 5:09:49 PM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : 1 counts of
IllegalAnnotationExceptions
2009-07-23 17:09:49,517 ERROR [STDERR] (TP-Processor3) Jul 23, 2009 5:09:49
PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
ID: 1
Encoding:
Content-Type: text/plain
Headers: {Content-Type=[text/plain]}
Payload: JAXBException occurred : 1 counts of IllegalAnnotationExceptions
--------------------------------------
2009-07-23 17:09:49,518 INFO [STDOUT] (TP-Processor3) 7145942
[TP-Processor3] ERROR STDERR - Jul 23, 2009 5:09:49 PM
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
ID: 1
Encoding:
Content-Type: text/plain
Headers: {Content-Type=[text/plain]}
Payload: JAXBException occurred : 1 counts of IllegalAnnotationExceptions
--------------------------------------
Issue #2
======
In my updatePilotLocations() - a POST, I am seeing null for
locations.getLocations():
2009-07-23 16:01:33,850 INFO [STDOUT] (TP-Processor2) 3050274
[TP-Processor2] ERROR STDERR - Jul 23, 2009 4:01:33 PM
org.apache.cxf.interceptor.LoggingInInterceptor logging
INFO: Inbound Message
----------------------------
ID: 1
Address: /rest/locationservices/pilot/
Encoding: ISO-8859-1
Content-Type: text/xml; charset=ISO-8859-1
Headers: {content-length=[62], host=[test.apps.com], user-agent=[Jakarta
Commons-HttpClient/3.0], Content-Type=[text/xml; charset=ISO-8859-1],
content-type=[text/xml; charset=ISO-8859-1], Accept=[text/xml]}
Payload: <Locations>
<Location>
<id>1</id>
</Location>
</Locations>
--------------------------------------
2009-07-23 16:01:34,023 WARN [com.apps.service.rest.LocationServices]
(TP-Processor2) Received empty location list.
2009-07-23 16:01:34,024 INFO [STDOUT] (TP-Processor2) 3050448
[TP-Processor2] WARN com.apps.service.rest.LocationServices - Received
empty location list.
Could someone please shed some light on these issues? I would really
appreciate your help!
Thanks
--
View this message in context:
http://www.nabble.com/CXF-2.2.2-handling-of-Collection-broken--tp24637431p24637431.html
Sent from the cxf-user mailing list archive at Nabble.com.