Hi, That is indeed the reason for the class cast exception, but on the server the Set is populated with AMRecord objects and after the Jackson representation un-marshalling the AMRecord object has become a LinkedHashMap.
So there has to be something going on in the Jackson/JSON representation implementation that prevents my custom class working in a collection, but fine when it's just on its own. regards Steve -- Steve Ferris : ForgeRock AS : e: [email protected] t: +44 (0)7813 709285 f: +44 (0)7971 042421 w: forgerock.com OpenAM, the new name for OpenSSO On 19 Apr 2011, at 3:40pm, Tim Peierls wrote: > A LinkedHashMap is not a Set. Could that explain the class cast exception? > > --tim > > On Tue, Apr 19, 2011 at 7:13 AM, Steve Ferris <[email protected]> > wrote: > Hi, > > I have a custom class AMRecord which is being handled in an unexpected way. > > Two RESTlet calls: > > @Get > public AMRecord read(String id) { > > and > > @Get > public Set<AMRecord> readWithSecKey(String id) { > > Jackson can cope with AMRecord as the read call works, my client code looks > like this: > > ClientResource resource = new ClientResource(resourceUrl + "/read"); > ReadResource readResource = resource.wrap(ReadResource.class); > > AMRecord record = readResource.read("43478392743"); > > I get back an AMRecord instance. > > But for the Set, on the client I get a class cast exception > > ClientResource resource = new ClientResource(resourceUrl + > "/readwithseckey"); > ReadWithSecKeyResource secReadResource = > resource.wrap(ReadWithSecKeyResource.class); > > Set<AMRecord> sessions = > secReadResource.readWithSecKey("uid=steve,ou=users,o=openam"); > > This is because the Set sessions has a LinkedHashMap rather than AMRecord > entries. The LinkedHashMap is populated with the data from the AMRecord that > should be present. > > Any ideas? > > thanks > Steve > > -- > Steve Ferris : ForgeRock AS : e: [email protected] > t: +44 (0)7813 709285 f: +44 (0)7971 042421 w: forgerock.com > OpenAM, the new name for OpenSSO > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2721416

