Hi Guy,

Maybe there's a problem with the media type produced by your resource method.


The attached TestResponseStatus works for me. However, when I comment out the @Produces annotation:

   @Path("/")
   public static class TestResourceImpl
   {
      @POST
      @Path("post")
//      @Produces("text/plain")
      public Response.Status post()
      {
         return Response.Status.OK;
      }
   }

I get

SEVERE: Failed executing POST /post
org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: javax.ws.rs.core.Response$Status of media type: application/octet-stream at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:67) at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:427) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) at org.jboss.resteasy.plugins.server.tjws.TJWSServletDispatcher.service(TJWSServletDispatcher.java:40) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at Acme.Serve.Serve$ServeConnection.runServlet(Serve.java:2331)
    at Acme.Serve.Serve$ServeConnection.parseRequest(Serve.java:2285)
    at Acme.Serve.Serve$ServeConnection.run(Serve.java:2057)
    at Acme.Utils$ThreadPool$PooledThread.run(Utils.java:1402)
    at java.lang.Thread.run(Thread.java:745)

status: Internal Server Error

Is that what you are seeing?

-Ron

On 05/04/2015 03:01 PM, Guy Rouillier wrote:
We have a webservice POST method that returns a Response.Status object
as the entity.  I've debugged this running method to verify that the
return value is Response.Status.OK.

We use the RestEasy client proxy to invoke our webservice methods.  The
approach works well for us, and our developers find the approach easy to
use.  However, in this case, the proxy is deserializing this return
object as Response.Status.INTERNAL_SERVER_ERROR.

Any idea on why this would happen?

Thanks.

--
Guy Rouillier


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

package org.jboss.resteasy.test.junk;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;

import junit.framework.Assert;

import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.jboss.resteasy.core.Dispatcher;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.jboss.resteasy.test.EmbeddedContainer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * 
 * @author <a href="ron.si...@jboss.com">Ron Sigal</a>
 * @version $Revision: 1.1 $
 *
 * Copyright May 11, 2015
 */
public class TestResponseStatus
{
   protected static ResteasyDeployment deployment;
   protected static Dispatcher dispatcher;

   public interface TestResource
   {
      @POST
      public Response.Status post();
   }
   
   @Path("/")
   public static class TestResourceImpl
   {
      @POST
      @Path("post")
//      @Produces("text/plain")
      public Response.Status post()
      {
         return Response.Status.OK;
      }
   }

   @Before
   public void before() throws Exception
   {
      Hashtable<String,String> initParams = new Hashtable<String,String>();
      Hashtable<String,String> contextParams = new Hashtable<String,String>();
      deployment = EmbeddedContainer.start(initParams, contextParams);
      dispatcher = deployment.getDispatcher();
      deployment.getRegistry().addPerRequestResource(TestResourceImpl.class);
   }

   @After
   public void after() throws Exception
   {
      EmbeddedContainer.stop();
      dispatcher = null;
      deployment = null;
   }

   @Test
   public void testProxy() throws Exception
   {
      ResteasyClient client = new ResteasyClientBuilder().build();
      ResteasyWebTarget target = client.target("http://localhost:8081/post";);
      TestResource tr = target.proxy(TestResource.class);
      Response.Status status = tr.post();
      System.out.println("status: " + status);
      Assert.assertEquals("OK", status.toString());
   }
}
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to