Ahh... thats it.. We have some reflection to do with Generic types,
and it seems that I re-ordered the generic types in the subclass so
that when it was looking for the object type it was infact getting the
primary key type.
Thanks heaps, I've been staring at this problem on and off for days
and the simple answer is always the easiest.
Thanks again.
Steve
On Wed, Sep 16, 2009 at 10:53 PM, Marc Hadley <Marc.Hadley_at_sun.com> wrote:
> What are you passing to the getEntity method ? The error message suggests
> you might be passing Integer.class since it is looking for a provider to
> convert the XML to an integer rather than an instance of PriceScaleList.
>
> Marc.
>
> On Sep 15, 2009, at 11:46 PM, Steve Mactaggart wrote:
>
>> Hi all,
>>
>> I have an application that consumes a Jersey endpoint, that has been
>> working for weeks, but all of a sudden has stopped working. I have
>> made what I believe to be un-related changes to the codebase but I
>> guess I have changed something. The changes were in relation to some
>> jersey "server" endpoints this app provides, but my issue seems to be
>> with the Jersey client.
>>
>> It looks like the default mapping for java.lang.Integer seems to have
>> been lost..
>>
>> If I request the url in a browser:
>> http://127.0.0.1:8080/data-14-SNAPSHOT/pricescale
>>
>> I get valid XML..
>> <?xml version="1.0" encoding="UTF-8"
>>
>> standalone="yes"?><priceScaleList><elements><name>Retail</name><order>1</order><priceScaleID>1</priceScaleID></elements><elements><name>Wholesale</name><order>2</order><priceScaleID>2</priceScaleID></elements><elements><name>Trade</name><order>3</order><priceScaleID>3</priceScaleID></elements></priceScaleList>
>>
>> If I use the Jersey Client to retrieve this it fails with the below
>> error message.
>>
>> 16 Sep 09 13:34:32:btpool0-1:GenericResource :ERROR : A message
>> body reader for Java type, class java.lang.Integer, and MIME media
>> type, application/xml, was not found
>> com.sun.jersey.api.client.ClientHandlerException: A message body
>> reader for Java type, class java.lang.Integer, and MIME media type,
>> application/xml, was not found
>> at
>> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:526)
>> at
>> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:491)
>> at
>> com.sun.jersey.api.client.WebResource.handle(WebResource.java:561)
>> at com.sun.jersey.api.client.WebResource.get(WebResource.java:179)
>> at
>> au.com.us.util.rest.BaseJerseyClient.get(BaseJerseyClient.java:159)
>> at
>> au.com.us.util.rest.GenericJerseyClient.findAll(GenericJerseyClient.java:92)
>> at
>> au.com.us.business.webapi.GenericResource.listElementsGET(GenericResource.java:43)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>>
>> The Java Class' are the same one used in the client as well as the
>> server..
>> The endpoint returns a PriceScaleList, which is a wrapper for a list
>> of PriceScale objects.
>>
>> @XmlRootElement
>> public class PriceScaleList implements GenericList<PriceScale> {
>>
>> private List<PriceScale> elements;
>>
>> public PriceScaleList() {
>> }
>>
>> public PriceScaleList(List<PriceScale> elements) {
>> this.elements = elements;
>> }
>>
>> public void setElements(List<PriceScale> elements) {
>> this.elements = elements;
>> }
>>
>> public List<PriceScale> getElements() {
>> return elements;
>> }
>>
>> @Override
>> public List<PriceScale> getActualElements() {
>> return getElements();
>> }
>> }
>>
>> @XmlRootElement
>> public class PriceScale implements Entity {
>>
>> private Integer priceScaleID;
>> private String name;
>> private Integer order;
>>
>> public PriceScale() {
>> }
>>
>> public PriceScale(Integer id) {
>> this.priceScaleID = id;
>> }
>>
>> <snipped 3x getter/setter>
>> }
>>
>> Any ideas what this issue is? Googling the mailing list and the wider
>> internet didn't turn up much.
>>
>> Cheers,
>> Steve
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>