NPE when trying to invoke method on RESTeasy client
wortmanb.bdw.techma.com Nov 15, 2010 10:53 AMHere's the client:
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 here's the interface it's instantiating:
@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); }
When I try to run this client code, I get this:
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
For the life of me I can't figure out what could be going wrong. I added the server-side project to the build path (in Eclipse, from where I'm running this client) which isn't my ultimate plan, but it gives the client side access to everything the server side has.
Any ideas for things to check next? I've verified that schema/schema1.xsd exists and contains the xml schema definition for the message type being sent.