Resource class:
@Path("/account/supplier")
@RequestScoped
public class SupplierAccountResource {
@PUT
@Path("create")
@Consumes(MediaType.APPLICATION_JSON)
public Response create(Account account, User user) {
//authentication and authorization
try {
supplierAccountService.create(account, user);
}
catch(DomainValidationException e) {
return e.getResponse();
}
return Response.ok().build();
}
}
*JSONConfiguration.FEATURE_POJO_MAPPING is true*
The create method is correct?
*HOW TO REQUEST CREATE USING CURL?*
I am trying to test a request using this curl command:
curl -v -Xput -HAccept:application/json -HContent-type:application/json *-d
'_at_account.json'* *-d '_at_user.json' *
http://localhost:8080/account/supplier/create
*account.json file: *
{"name":"MyAccount", "group":"SUPPLIER", "category":"BUSINESS"}
*user.json file: *{"email":"user_at_bragile.com","unsecurePassword":"12345678"}
*Exception:*
Feb 11, 2012 2:21:17 PM com.sun.jersey.spi.container.ContainerResponse
mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not
be mapped to a response, re-throwing to the HTTP container
java.io.EOFException: *No content to map to Object due to end of input*
at
org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2766)
at
org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2682)
at
org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1308)
at
org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
at
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.readFrom(JacksonProviderProxy.java
.....
*What is wrong?*