title: 500 Internal server error - Jersey (Java web service)
body: <p>I have a Java REST-Service which provides several CRUD services to clients (using Grizzly and Jersey). I have been searching for this problem for days now and i really don't get it, because there is another call provided by the server which is nearly the same and it works just fine.... </p>
  
  <p>Here is a code snippet of a service that doesn't work:</p>
  
  <pre><code>@Path("objets")
  public class ObjetResource {
  
      @PUT
      @Path("/{code}")
      @Consumes(MediaType.APPLICATION_JSON)
      public void updateObject(
        @PathParam("code") String code,
        final Objet updatedObject){
  
          System.out.println("UpdateObject is called!");
  
          }
  }
  </code></pre>
  
  <p>This service is supposed to be called with the following url: <a href="http://localhost:8080/webservice/objets/newCode" rel="nofollow">http://localhost:8080/webservice/objets/newCode</a></p>
  
  <p>Here is a service that works:</p>
  
  <pre><code>@Path("domaines")
  public class DomaineResource {
  
      @PUT
      @Path("/{nom}")
      @Consumes(MediaType.APPLICATION_JSON)
      public void updateDomaine(
          @PathParam("nom") String nom,
          final Domaine updatedDomaine
          ){
  
          System.out.println("UpdateDomaine is called!");
  
      }
  }
  </code></pre>
  
  <p>This service works when called with the following url: <a href="http://localhost:8080/webservice/domaines/newDomaine" rel="nofollow">http://localhost:8080/webservice/domaines/newDomaine</a></p>
  
  <p>Sadly I receive a "500 internal server error"... And of course "This function is called" is never displayed... ):
  I've tried deleting the whole "updateObject" function, and when I do so, the error becomes "405 Method not allowed" D:!</p>
  
  <p>Do you have any idea why I'm having this problem? </p>
  
  <p>Is there any way to have more information about the error that is occuring? It's really hard to solve my problem with this little information ):</p>
  
  <p><strong>EDIT</strong>:
  I've tried several things to correct my problem.
  First, I've tried to simplify my "updateObjet" function. I've noticed something quite wierd:</p>
  
  <p>When I send the following json:</p>
  
  <pre><code>{ "code" : "codeValue" }
  </code></pre>
  
  <p>"UpdateObject is called" is successfully displayed. However, if I send </p>
  
  <pre><code>{ "code" : "codeValue", "type" : "platform.field" }
  </code></pre>
  
  <p>Nothing is displayed.</p>
  
  <p>Here is the code of my class Objet:</p>
  
  <pre><code>package classes;
  
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  
  @XmlRootElement
  public class Objet extends Model{
  
  @XmlElement(name="code")
  private String code;
  
  @XmlElement(name="type")
  private String type;
  
  @XmlElement(name="parent")
  private String parent;
  
  @XmlElement(name="annotations")
  private String annotations;
  
  @XmlElement(name="ontologyuri")
  private String ontologyuri;
  
  @XmlElement(name="access")
  private String access;
  
  public Objet(){
  
  }
  
  public Objet(String code, String type, String parent, String annotations, String ontologyuri, String access){
      this.code = code;
      this.type = type;
      this.parent = parent;
      this.annotations = annotations;
      this.ontologyuri = ontologyuri;
      this.access = access;
  }
  
  public void setCode(String code) {
      this.code = code;
  }
  
  public String getCode(){
      return this.code;
  }
  
  public String getType() {
      return type;
  }
  
  public void setType(String type) {
      this.type = type;
  }
  
  public String getParent() {
      return parent;
  }
  
  public void setParent(String parent) {
      this.parent = parent;
  }
  
  public String getAnnotations() {
      return annotations;
  }
  
  public void setAnnotations(String annotations) {
      this.annotations = annotations;
  }
  
  public String getOntologyuri() {
      return ontologyuri;
  }
  
  public void setOntologyuri(String ontologyuri) {
      this.ontologyuri = ontologyuri;
  }
  
  public String getAccess(){
      return access;
  }
  
  public void setAccess(String access) {
      this.access = access;
  }
  
  public String toString(){
      return "Code : " + getCode() + " Type : " + getType() + " Parent : " + getParent() + " Annotations : " + getAnnotations() + " ontologyuri : " + getOntologyuri() + " access : " + getAccess();
  }
  
  }
  </code></pre>
  
  <p>And here is the code of my class Domaine:</p>
  
  <pre><code>package classes;
  
  import java.util.ArrayList;
  
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement
  public class Domaine extends Model{
  
  @XmlElement(name="nom")
  private String nom;
  
  @XmlElement(name="adresse")
  private String adresse;
  
  @XmlElement(name="description")
  private String description;
  
  @XmlElement(name="access")
  private String access;
  
  @XmlElement(name="plateformes")
  private ArrayList&lt;Plateforme&gt; plateformes;
  
  public Domaine(){}
  
  public Domaine(String nom, String adresse, String description, String access){
      this.nom = nom;
      this.adresse = adresse;
      this.description = description;
      this.access = access;
  }
  
  public Domaine(String nom, String adresse, String description, String access, ArrayList&lt;Plateforme&gt; plateformes){
      this.nom = nom;
      this.adresse = adresse;
      this.description = description;
      this.access = access;
      this.plateformes = plateformes;
  }
  
  public String getNom(){
      return this.nom;
  }
  public void setNom(String nom){
      this.nom = nom;
  }
  
  public String getAdresse(){
      return this.adresse;
  }
  public void setAdresse(String adresse){
      this.adresse = adresse;
  }
  
  public String getDescription(){
      return this.description;
  }
  public void setDescription(String desc){
      this.description = desc;
  }
  
  public String getAccess(){
      return this.access;
  }
  public void setAccess(String access){
      this.access = access;
  }
  
  //Manipulation des plateformes
  public ArrayList&lt;Plateforme&gt; getPlateformes(){
      return this.plateformes;
  }
  
  public void addPlateforme(Plateforme p){
      this.plateformes.add(p);
  }
  
  public void removePlateforme(Plateforme p){
      this.plateformes.remove(p);
  }
  
  public String toString(){
      return "Nom : " + getNom() + " Adresse : " + getAdresse() + " Description : " + getDescription() + " Access " + getAccess();
  }
  
  }
  </code></pre>
  
  <p><strong>EDIT 2</strong>:
  I've continued trying to understand my error and have a few things to add that may help:
  First of all, I've noticed that when I do a "GET" on <a href="http://localhost:8080/webservice/domaines" rel="nofollow">http://localhost:8080/webservice/domaines</a> , I receive the following JSON:</p>
  
  <pre><code>[{"type":"domaine","nom":"DomaineTest0","adresse":"domaine de test 0","description":"","access":"test"},
  {"type":"domaine","nom":"DomaineTest1","adresse":"Domaine de test 1","description":""}]
  </code></pre>
  
  <p>As you can see, there is a "type" field, that is not specified in my class Domaine. I've searched a bit in Jersey's documentation, but for the moment I can't understand where this "type" field comes from.
  What's interesting with this information is that the class Objet I specified has a "type" field. I was thinking maybe this "type" field that appears mysteriously is interfering with the "type" field of my Objet?</p>