title: A message body writer for Java type, class myPackage.B, and MIME media type, application/octet-stream, was not found
body: <p>I am new at RESTful webservices and was trying to update my <code>@OneToMany</code> relationship from a standalone client application, but I am not able to do that. I am using the Jersey implementation of JAX-RS that ships with Glassfish 3.1.1.</p>
  
  <p>I have a class <code>A</code> that has a <code>@OneToMany</code> relationship with class <code>B</code>. </p>
  
  <p><code>MyRestClient</code> is my standalone client that is calling my RESTful webservice which has been deployed on Glassfish 3.1.1.</p>
  
  
  
  <p>MyRestClient.java</p>
  
  <pre class="lang-java prettyprint-override"><code>public class MyRestClient {
      public static void main(String[] args) {    
          Client client = Client.create();        
          WebResource resource = client.resource("http://localhost:8080/myapp/rest/a/update/123");    
          B b1 = new B("debris");     
          ClientResponse response = resource.put(ClientResponse.class, b1);
          System.out.println(response.getEntity(A.class).getTitle() + " has " + response.getEntity(A.class).getBList().size() + " Bs.");
      }
  }
  </code></pre>
  
  <p><code>AResource</code> is an EJB session bean which I am using as RESTful webservice.</p>
  
  <p>AResource.java</p>
  
  <pre class="lang-java prettyprint-override"><code>@Stateless
  @Path("/a")
  public class AResource {
  
      @EJB
      private AManager aManager;
  
      @PUT
      @Consumes(MediaType.APPLICATION_XML)
      @Produces(MediaType.APPLICATION_XML)
      @Path("/update/{id}")
      public Response updateA(B b, @PathParam("id") int id) {
          A a = aManager.findAById(id);
          a.addB(b);
          return Response.status(Status.OK).entity(a).build();
      }
  }
  </code></pre>
  
  <p>When I run the client I get the following error message:
  <strong>com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class myPackage.B, and MIME media type, application/octet-stream, was not found</strong>.</p>
  
  <p>Following are the domain objects in my standalone client application which is making a call to the <code>AResource</code> EJB session bean which I am using as the RESTful webservice.</p>
  
  <p>A.java</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlRootElement
  public class A implements Serializable{ 
  
      private List&lt;B&gt; bList = new ArrayList&lt;B&gt;();
      public List&lt;B&gt; getBList() {
          return bList;
      }
      //remaining code
  
  }
  </code></pre>
  
  <p>B.java</p>
  
  <pre class="lang-java prettyprint-override"><code>public class B implements Serializable {
  
      private String text;
      private A a;    
  
  
      @XmlTransient
      public A getA() {
          return a;
      }
  
      public void afterUnmarshal(Unmarshaller u, Object parent) {
          this.a = (A) parent;
      }
      //remaining code
  
  }
  </code></pre>
  
  <p>Could someone help me understand why this is happening and how I should solve this problem?</p>