According to the man page on curl, "Thus, using '-d name=daniel -d
skill=lousy' would generate a post chunk that looks like
'name=daniel&skill=lousy'.", so your -d options appear to be missing the
"name=value" format. I'd also check the "@" symbols you're passing in
(as in "@account.json"), maybe that would need to be escaped with curl;
I don't know.
The Jersey jaxb-from-json sample
(
http://java.net/projects/jersey/sources/svn/show/trunk/jersey/samples/json-from-jaxb?rev=4816)
has an example of using "curl" (see the HTML readme) although it doesn't
use the -d option. Still, it may be good to look at if you suspect the
problem is with the REST service.
Regards,
Glen
On 02/11/2012 11:27 AM, Rodrigo de Alvarenga Mattos wrote:
> 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
> <mailto: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?*
--
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza