title: HTTP 500 Internal Server Error in simple REST based program. Confused in GET and POST while receiving/sending response from server
body: <p>I am implementing a basic client server architecture using REST services for the first time. This time I making it more complicated with including some more classes and services with sharing class objects as parameters between client and server. I am running server on ApacheTomcat7. It is getting executed successfully. When I am running my client it is giving me error: <code>javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error</code> I tried debugging my code, it seems like I am not properly receiving/sending response. I know its not wise idea to share all classes here but I has no choice since it has wasted my time a lot. Any help will be appreciated. Thanks in advance. </p>
  
  <p>Following is my ImageProgress class. This class is present at both server and client.</p>
  
  <pre><code>@XmlRootElement
  public class ImageProgress{
      private String name;
  
      public ImageProgress( String image_name){
          this.name = image_name;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName( String name ){
          this.name = name;
      }
  }
  </code></pre>
  
  <p>HPCResponse is the class whose object will be returned to client as the server response. HPCResponse will basically return the ImageProgress object which will give me the intended result.</p>
  
  <pre><code>@XmlRootElement
  public class HPCResponse
  {
      private ImageProgress imgProgress;
  
      public ImageProgress getImgProgress() {
          return imgProgress;
      }
  
      public void setImgProgress(ImageProgress imgProgress) {
          this.imgProgress = imgProgress;
      }
  }
  </code></pre>
  
  <p>Following is the service class from server named HpcService which will return the HPCResponse's object as response. As you can see the method startAnalysing accepts object of HPCInfo. Description of HPCInfo is also given below.</p>
  
  <pre><code>@Path( "/hpc" )
  @Consumes( MediaType.APPLICATION_XML )
  @Produces( MediaType.APPLICATION_XML )
  public class HpcService{
  
      public HPCInfo hpcInfo;
      public HPCResponse hpcResponse;
  
      @POST
      @Path( "/analyze" )
      public HPCResponse startAnalysing(HPCInfo _hpcInfo){
  
          System.out.println( "Started Analyzing..." );
  
          hpcInfo = _hpcInfo;
          hpcInfo.getImagePath();        
  
          hpcResponse = new HPCResponse();
          ImageProgress iProg = new ImageProgress(hpcInfo.getImagePath());
          hpcResponse.setImgProgress(iProg);
  
          System.out.println("Returning response...");
          return hpcResponse;
      }
  }
  </code></pre>
  
  <p>HPCInfo class is also at both client and server. HPCInfo class:</p>
  
  <pre><code>    @XmlRootElement
      public class HPCInfo
      {
          private String imagePath = "";
  
          public String getImagePath(){
              return imagePath;
          }
  
          public void setImagePath( String imagePath ){
              this.imagePath = imagePath;
          }
      }
  </code></pre>
  
  <p>And finally its my client calling for the HPCService.</p>
  
  <pre><code>public class TestClient {
      private static String webServiceURI = "http://localhost:8080/TestServer123";
      public static void main(String[] args) {
          String input = "ABNKidney.scn";
          ClientConfig clientConfig = new ClientConfig();
          Client client = ClientBuilder.newClient(clientConfig);
          URI serviceURI = UriBuilder.fromUri(webServiceURI).build();
  
          WebTarget webTarget = client.target(serviceURI);
  
          HPCInfo info = new HPCInfo();
          info.setImagePath(input);
  
          webTarget = webTarget.path("test").path("hpc").path("analyze");
  
          HPCResponse hResponse = webTarget.request().accept(MediaType.APPLICATION_XML).post(Entity.entity(info, MediaType.APPLICATION_XML), HPCResponse.class);
      }
  }
  </code></pre>
  
  <p>This is the full error description I am getting:</p>
  
  <pre><code>javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
      at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:968)
      at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:795)
      at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91)
      at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:683)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
      at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:679)
      at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:435)
      at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:338)
      at com.TestClient.main(TestClient.java:34)
  </code></pre>