PUT 和 POST 不能在 J2SE 平台上工作(RESTLET 版本 3.0-M1)

PUT and POST not working from J2SE platform (RESTLET Version 3.0-M1)

我正在处理一个使用 GWT 和 J2SE 客户端的项目。 GWT 部分运行良好,但现在 J2SE 客户端出现问题;

"The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions"

"The serialized representation must have this media type: application/x-java-serialized-object or this one: application/x-java-serialized-object+xml"

此代码在 months/versions 之前工作...PUT 和 POST 在 GET 工作时都会产生此错误。 这里有什么问题吗?

这是一个非常简单的测试用例

// 共享接口

public interface J2SeClientServerResourceInt
{
   @Post("json")
   public J2seStatusDto postJ2seStatus(J2seStatusDto pJ2seStatusDto);
}

//Java豆子

  public class J2seStatusDto implements Serializable
    {
        private static final long serialVersionUID = 6901448809350740172L;

        private String mTest;

        public J2seStatusDto()
        {
        }

        public J2seStatusDto(String pTest)
        {
            setTest(pTest); 
        }

        public String getTest()
        {
            return mTest;
        }

        public void setTest(String pTest)
        {
            mTest = pTest;
        }
    }

// 服务器

public class J2seServerResource extends ClaireServerResource implements J2SeServerResourceInt
{
    @Override
    public J2seStatusDto postJ2seStatusDto(J2seStatusDto pJ2seStatusDto)
    {
        return pJ2seStatusDto;
    }
}

// J2SE 客户端

public class ClaireJsSeTestClient
{
    public static void main(String[] args)
    {
        Reference lReference = new Reference("http://localhost:8888//rest/j2se");
        ClientResource lClientResource = new ClientResource(lReference);
        lClientResource.accept(MediaType.APPLICATION_JSON);
        J2SeServerResourceInt lJ2SeServerResource = lClientResource.wrap(J2SeServerResourceInt.class);
        J2seStatusDto lJ2seStatusDto = new J2seStatusDto("TEST");
        J2seStatusDto lJ2seResultDto = lJ2SeServerResource.postJ2seStatusDto(lJ2seStatusDto);
    }
}

// Maven J2Se 客户端

   <dependencies>
        <dependency>
            <groupId>org.restlet.jse</groupId>
            <artifactId>org.restlet</artifactId>
            <version>3.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.restlet.jse</groupId>
            <artifactId>org.restlet.ext.jackson</artifactId>
            <version>3.0-M1</version>
        </dependency>
    </dependencies>

// Maven GAE 服务器

  <dependency>
        <groupId>org.restlet.gae</groupId>
        <artifactId>org.restlet</artifactId>
        <version>3.0-M1</version>
    </dependency>
    <dependency>
        <groupId>org.restlet.gae</groupId>
        <artifactId>org.restlet.ext.servlet</artifactId>
        <version>3.0-M1</version>
    </dependency>
    <dependency>
        <groupId>org.restlet.gae</groupId>
        <artifactId>org.restlet.ext.jackson</artifactId>
        <version>3.0-M1</version>
    </dependency>
    <dependency>
        <groupId>org.restlet.gae</groupId>
        <artifactId>org.restlet.ext.gwt</artifactId>
        <version>3.0-M1</version>
    </dependency>
    <dependency>
        <groupId>org.restlet.gwt</groupId>
        <artifactId>org.restlet</artifactId>
        <version>3.0-M1</version>
        <scope>compile</scope>
    </dependency>

Thierry Boileau 解决了我们的问题(错误);

https://github.com/restlet/restlet-framework-java/issues/1029#issuecomment-76212062

由于GAE平台的限制(不支持chunked编码)必须指定请求实体先缓冲;

cr.setRequestEntityBuffering(true);

感谢restlet.com

的大力支持