|
From: Josiah H. <jos...@gm...> - 2013-07-18 04:45:17
|
Hi folks,
The issue turned out to be that I did not add a content-type header to the
request. Bit of a silly oversight, but the fact that it was being parsed
into a map (the Jackson default behavior, I understand) made me think that
it was being handled by the correct handlers.
Thanks!
Josiah
On Sat, Jul 13, 2013 at 9:32 PM, Josiah Haswell <jos...@gm...>wrote:
> Hi Folks,
>
> For some reason, I cannot seem to get RESTEasy to deserialize an object
> into the correct type. Here's what I'm trying to do:
>
>
> I have the class:
>
>
> @XmlRootElement
> public class Category {
> private String id;
> private String name;
> private String description;
>
> public String getId() {
> return id;
> }
>
> public void setId(String id) {
> this.id = id;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getDescription() {
> return description;
> }
>
> public void setDescription(String description) {
> this.description = description;
> }
> }
>
> And the REST Service:
>
> @Path("cat")
> public class DefaultCatEndpoint {
> @PUT
> @Path("save")
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> public Category save(Category cat) {
> return cat;
> }
> }
>
>
> And I keep getting the exception:
>
>
>
> Bad arguments passed to public rest.Category
> rest.DefaultCatEndpoint.save(rest.Category) (
> java.util.LinkedHashMap {id=4c7e2662-0095-4c92-9e7f-7f43af62daee,
> name=testname,
> description=description}
>
>
> My web.xml file is:
>
>
> <web-app
> version="3.0"
> xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
> >
>
> <context-param>
> <param-name>resteasy.scan</param-name>
> <param-value>true</param-value>
> </context-param>
>
> <context-param>
> <param-name>resteasy.servlet.mapping.prefix</param-name>
> <param-value>/test</param-value>
> </context-param>
> <context-param>
> <param-name>resteasy.resource.method-interceptors</param-name>
> <param-value>
> org.jboss.resteasy.core.ResourceMethodSecurityInterceptor
> </param-value>
> </context-param>
>
> <listener>
>
> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
> </listener>
>
> <servlet>
> <servlet-name>Resteasy</servlet-name>
>
> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
> <init-param>
> <param-name>javax.ws.rs.Application</param-name>
> <param-value>app.RestApplication</param-value>
> </init-param>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>Resteasy</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
> And I have:
>
> <dependency>
> <groupId>org.jboss.resteasy</groupId>
> <artifactId>resteasy-jaxrs</artifactId>
> <version>${resteasy.version}</version>
> <scope>provided</scope>
> </dependency>
>
>
> <dependency>
> <groupId>org.jboss.resteasy</groupId>
> <artifactId>resteasy-jackson-provider</artifactId>
> <version>${resteasy.version}</version>
> </dependency>
>
>
> As my dependencies.
>
> Any help would be very much appreciated! I'm testing this on JBoss AS 7.1
>
> Josiah
>
>
|