Widfly中的JAX-RS表格

时间:2016-07-06 18:36:25

标签: java jboss jax-rs wildfly

我需要对接口进行REST调用。为此,我使用以下代码:

ClientConfig config = new ClientConfig();
Client client = ClientBuilder.newClient(config);
Response res = client.target(url).
    request().
    header("Authorization", "Basic " + basicAuthString).
    buildPost(Entity.form(new Form("grant_type", "client_credentials"))).
    invoke();

在使用JAX-RS的独立应用程序中,这可以按预期工作。当我在Wildfly应用程序服务器中使用该代码时,出现以下错误:

20:16:15,186 ERROR [stderr] (default task-5) Caused by:
javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/x-www-form-urlencoded type: javax.ws.rs.core.Form

Wildfly不知道如何处理javax.ws.rs.core.Form,这会创建Content-Type: application/x-www-form-urlencoded。我想念哪个依赖?

[修改:2016年7月7日]

我想发送的任何数据都会出现此错误。这引发了类似的错误:

ClientConfig config = new ClientConfig();
Client client = ClientBuilder.newClient(config);
Response res = client.target(url).
    request().
    post(Entity.entity("DATA", MediaType.TEXT_PLAIN));

1 个答案:

答案 0 :(得分:0)

最后,经过一天的调试:删除ClientConfig是解决方案!

Client client = ClientBuilder.newClient();
Response res = client.target(url).
    request().
    post(Entity.entity("DATA", MediaType.TEXT_PLAIN));