A message body writer for Java type, class myPackage.B, and MIME media type, application/octet-stream, was not found

后端 未结 10 1455

I am new at RESTful webservices and was trying to update my @OneToMany relationship from a standalone client application, but I am not able to do that. I am usi

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 07:02

    In your client code you are not specifying the content type of the data you are sending - so Jersey is not able to locate the right MessageBodyWritter to serialize the b1 object.

    Modify the last line of your main method as follows:

    ClientResponse response = resource.type(MediaType.APPLICATION_XML).put(ClientResponse.class, b1);
    

    And add @XmlRootElement annotation to class B on both the server as well as the client sides.

提交回复
热议问题