[
https://issues.jboss.org/browse/WFLY-9041?page=com.atlassian.jira.plugin....
]
Chao Wang moved JBEAP-11920 to WFLY-9041:
-----------------------------------------
Project: WildFly (was: JBoss Enterprise Application Platform)
Key: WFLY-9041 (was: JBEAP-11920)
Workflow: GIT Pull Request workflow (was: CDW with loose statuses v1)
Component/s: REST
(was: REST)
Affects Version/s: 11.0.0.Alpha1
(was: 7.0.6.GA)
(was: 7.1.0.ER1)
"Arguments must not be null" when sending a null JSON
object with ResteasyWebTarget
-----------------------------------------------------------------------------------
Key: WFLY-9041
URL:
https://issues.jboss.org/browse/WFLY-9041
Project: WildFly
Issue Type: Bug
Components: REST
Affects Versions: 11.0.0.Alpha1
Reporter: Chao Wang
Assignee: Alessio Soldano
Having a very simple WS application with a REST endpoint that consumes a JSON object:
{code:java}
@Path("hello")
public class HelloWorld {
@POST
@Path("entity")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
public Greeting helloEntity(Greeter greeter) {
return new Greeting(greeter);
}
}
{code}
If the resteasy-client with the the _ResteasyWebTarget_ proxy is used:
{code:java}
System.out.println(
((ResteasyWebTarget)
ClientBuilder.newClient()
.target("http://jboss.sample.com:8080")
.path("resteasy-test")
.path("ws")
.path("hello"))
.proxy(HelloWorldInterface.class)
.helloEntity(null));
{code}
The following exception is thrown at client side (no data is sent):
{code}
java.lang.IllegalArgumentException: Arguments must not be null.
at javax.ws.rs.core.GenericEntity.<init>(GenericEntity.java:148)
at
org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.MessageBodyParameterProcessor.process(MessageBodyParameterProcessor.java:35)
at
org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.createRequest(ClientInvoker.java:135)
at
org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:101)
at
org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:64)
at com.sun.proxy.$Proxy39.helloEntity(Unknown Source)
at com.redhat.sample.test.Client.main(Client.java:63)
{code}
You can send a null using the standard jax-rs methods:
{code:java}
System.out.println(ClientBuilder.newClient()
.target("http://jboss.sample.com:8080")
.path("resteasy-test")
.path("ws")
.path("hello")
.path("entity")
.request(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.post(Entity.entity(null, MediaType.APPLICATION_JSON))
.readEntity(Greeting.class));
{code}
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)