title: Jersey RESTful Service, Error 500
body: <p>I am new to Restful web services. I want to access the Server via a Jersey Client. But I am getting a 500 error. What i am trying to do is submit an table name through the client end and retrieve the table contents as a JSON. Can anyone please find the error here?</p>
  
  <p>This is my client end</p>
  
  <pre><code> public JSONObject loadTable(String tablename) throws ClientProtocolException, IOException {
      pathParams.add("tablename", tablename);
      JSONObject jsontable = service.path("access").path("loadtable").queryParams(pathParams).get(JSONObject.class);
      return jsontable;
  }
  </code></pre>
  
  <p>This is my Server end</p>
  
  <pre><code>@Path("/loadtable")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.TEXT_PLAIN)
  public JSONObject loadTable(@QueryParam("tablename") String tablename) throws Exception {
      List&lt;Pricing&gt; pricing = new ArrayList&lt;Pricing&gt;();
      try {
          query = c.prepareStatement("select * from '" + tablename + "'");
          ResultSet ets_rs = query.executeQuery();
  
          while (ets_rs.next()) {
              pricing.add(new Pricing(ets_rs.getString(1), ets_rs.getString(2),  ets_rs.getString(3), ets_rs.getString(4), ets_rs.getString(5), ets_rs.getString(6)));
          }
          query.close();
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          if (c != null) {
              c.close();
          }
      }
      JSONObject jsonTable = JsonConvert.getJsonFromPricing(pricing);
      System.out.println(jsonTable);
      return jsonTable;
  }
  </code></pre>
  
  <p>The Pricing class in the Server end converts the Result set to a JSON.</p>
  
  <p>This is the StackTrace:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" com.sun.jersey.api.client.UniformInterfaceException: GET http://localhost:8080/ServerETS/resources/access/loadtable?tablename=prices returned a response status of 500
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:563)
      at com.sun.jersey.api.client.WebResource.get(WebResource.java:179)
      at Link.ClientLink.loadTable(ClientLink.java:60)
      at Interfaces.Pricing.loadTable(Pricing.java:112)
      at Interfaces.Pricing.&lt;init&gt;(Pricing.java:32)
      at Interfaces.MainMenu.panelPricing(MainMenu.java:1026)
      at Interfaces.AdminData.btnAdminDataOKActionPerformed(AdminData.java:150)
      at Interfaces.AdminData.access$000(AdminData.java:26)
      at Interfaces.AdminData$1.actionPerformed(AdminData.java:70)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
      at java.awt.Component.processMouseEvent(Component.java:6288)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
      at java.awt.Component.processEvent(Component.java:6053)
      at java.awt.Container.processEvent(Container.java:2041)
      at java.awt.Component.dispatchEventImpl(Component.java:4651)
      at java.awt.Container.dispatchEventImpl(Container.java:2099)
      at java.awt.Component.dispatchEvent(Component.java:4481)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
      at java.awt.Container.dispatchEventImpl(Container.java:2085)
      at java.awt.Window.dispatchEventImpl(Window.java:2478)
      at java.awt.Component.dispatchEvent(Component.java:4481)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
      at java.awt.EventQueue.access$000(EventQueue.java:84)
      at java.awt.EventQueue$1.run(EventQueue.java:602)
      at java.awt.EventQueue$1.run(EventQueue.java:600)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
      at java.awt.EventQueue$2.run(EventQueue.java:616)
      at java.awt.EventQueue$2.run(EventQueue.java:614)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  </code></pre>
  
  <p>And this is the GlassFish Server Log</p>
  
  <pre><code>Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class org.json.simple.JSONObject, and Java type class org.json.simple.JSONObject, and MIME media type application/json was not found
      ... 33 more
  </code></pre>