Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-480

NPE when trying to invoke method on RESTeasy client

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • 2.1.0.GA
    • 1.1.RC2
    • None
    • None

      When trying to run a test client against a RESTeasy web service, I encounter the following error:

      java.lang.RuntimeException: java.lang.NullPointerException
      at org.jboss.resteasy.client.core.ClientInvoker.invoke(ClientInvoker.java:104)
      at org.jboss.resteasy.client.core.ClientProxy.invoke(ClientProxy.java:59)
      at $Proxy13.saveMessage(Unknown Source)
      at com.techma.shepherd.client.TestClient.main(TestClient.java:36)
      Caused by: java.lang.NullPointerException
      at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:114)
      at org.jboss.resteasy.client.ClientRequest.writeRequestBody(ClientRequest.java:372)
      at org.jboss.resteasy.client.core.ApacheHttpClientExecutor$ClientRequestEntity.<init>(ApacheHttpClientExecutor.java:105)
      at org.jboss.resteasy.client.core.ApacheHttpClientExecutor.loadHttpMethod(ApacheHttpClientExecutor.java:173)
      at org.jboss.resteasy.client.core.ApacheHttpClientExecutor.execute(ApacheHttpClientExecutor.java:53)
      at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:338)
      at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:535)
      at org.jboss.resteasy.client.core.ClientInvoker.invoke(ClientInvoker.java:100)
      ... 3 more

      The client code:

      public class TestClient {

      public static void main(String[] args) {
      MessageTFM m = new MessageTFM();
      m.setMsgId(new BigDecimal(42));
      m.setCreatedDate(new Date());
      m.setDestinationId("ABCD1234");
      m.setMsgComp(new BigDecimal(2));
      m.setNumLocTfmsProvided(new BigDecimal(14));
      m.setSourceId("WXYZ6789");
      m.setVersionMajor("4");
      m.setVersionMinor("1");
      IMessageTFMResource client = ProxyFactory.create(
      IMessageTFMResource.class,
      "http://localhost:8080/GPRI/seam/resource/rest");
      try

      { Response r = client.saveMessage(m); assert r.getStatus() == 201; }

      catch (Exception e)

      { // TODO Auto-generated catch block e.printStackTrace(); }

      }
      }

      and the interface class:

      @Path("/messages/TFM")
      public interface IMessageTFMResource {

      @GET
      @Produces("application/xml")
      @Path("

      {id}")
      public MessageTFM getMessage(@PathParam("id") BigDecimal id);

      @POST
      @Consumes("application/xml")
      public Response saveMessage(MessageTFM msg);

      @PUT
      @Produces("application/xml")
      @Consumes("application/xml")
      @Path("/{id}

      ")
      public Response updateMessage(@PathParam("id") int id, MessageTFM msg);

      @DELETE
      @Consumes("application/xml")
      @Produces("application/xml")
      @Path("/

      {id}

      ")
      public Response deleteMessage(@PathParam("id") int id);

      @POST
      @Produces("application/xml")
      @Consumes("application/xml")
      @Path("/matching")
      public List<MessageTFM> getMatchingMessages(MessageTFM msg);

      }

      I asked about this on the Seam forums and was told to post this as a bug here. If it's a configuration (or other) issue on my side, I'm perfectly ready to admit as much. I can provide the MessageTFM class if needed but omitted it for brevity (it's rather lengthy).

      Thanks.

              patriot1burke@gmail.com Bill Burke (Inactive)
              wortmanb_jira Bret Wortman (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: