Hi Aditya,
The exception is saying that the Jersey runtime does not know how to
serialize an instance of Address[] to create a entity (a representation)
that is returned in the body of the HTTP response message.
If you want to provide your own way of serializing an instance of
Address or Address[] (and also deserializing) you need to implement an
EntityProvider specific to those types. See here [1] for how to do this.
Alternatively if you want to serialize out as XML you could use JAXB
(although returning arrays of JAXB beans are not yet supported, but
potentially could be if the root element can be inferred). But... that
may take the fun out of things :-)
Paul.
[1]
http://blogs.sun.com/sandoz/entry/plugable_types_with_jax_rs
Aditya Gore wrote:
> Hi All,
>
> I am trying to write a simple address book app using jersey. My
> application right now is a simple resource class that supports only
> GET and returns an array of hardcoded Address objects. An Address
> object is a very simple object with just 2 methods returning Strings
> (getHouse() and getStreet()). On executing a GET I see the error
> below. Please can someone point out where I am going wrong?
>
>
> java.lang.IllegalArgumentException: A entity provider for type, class
> [Laddressbook.resources.Address;, is not supported
> at com.sun.ws.rest.impl.provider.ProviderFactoryImpl.createEntityProvider(ProviderFactoryImpl.java:67)
> at com.sun.ws.rest.impl.container.httpserver.HttpServerResponseAdaptor.commit(HttpServerResponseAdaptor.java:66)
> at com.sun.ws.rest.impl.container.httpserver.HttpHandlerContainer.handle(HttpHandlerContainer.java:64)
> at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
> at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
> at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
> at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:556)
> at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
> at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:528)
> at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java:125)
> at sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:353)
> at sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:327)
> at java.lang.Thread.run(Thread.java:619)
>
> thanks,
> :aditya
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109