On 11/1/13 3:46 PM, Nick wrote:
> Made a minor modification to the client to send a String instead of a
> JsonObject to the web service (running on Glassfish 4) and that worked.
>
> Is jersey-media-json-processing.jar required on the client side?
I think that is required, otherwise message body readers/writers won't
be discovered by jersery runtime. Is your client running in a standalone
environment or in GlassFish ?
I know that JAX-RS REST service that returns JSON objects work fine on
GlassFish(have a sample in the workspace). I haven't tried the client
side. If the client doesn't work, let me know.
>
>
> On 1 November 2013 11:24, Jitendra Kotamraju
> <jitendra.kotamraju_at_oracle.com <mailto:jitendra.kotamraju_at_oracle.com>>
> wrote:
>
> On 10/31/13 3:16 PM, Nick wrote:
>> Receiving the same output after including the missing JAR
>> (jsonp-jaxrs-1.0). Even did a clean and build before running the
>> client with the added JAR.
> GlassFish includes jersey-media-json-processing.jar. I think that
> is also required to discover these message body reader/writers. If
> that doesn't work, post to jersey mailing list.
>
> Jitu
>
>>
>>
>> On 1 November 2013 10:56, Jitendra Kotamraju
>> <jitendra.kotamraju_at_oracle.com
>> <mailto:jitendra.kotamraju_at_oracle.com>> wrote:
>>
>> On 10/31/13 2:22 PM, Nick wrote:
>>> Have written a small REST client using Jersey and JSONP
>>> libraries. After running the client the following appears in
>>> the output window:
>>>
>>>
>>> ====================================================
>>> run:
>>> Exception in thread "main"
>>> org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:
>>> MessageBodyWriter not found for media type=application/json,
>>> type=class
>>> org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl,
>>> genericType=class
>>> org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.
>>> at
>>> org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
>>> at
>>> org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
>>> at
>>> org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1139)
>>> at
>>> org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:433)
>>> at
>>> org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:310)
>>> at
>>> org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:216)
>>> at
>>> org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:217)
>>> at
>>> org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:671)
>>> at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
>>> at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
>>> at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
>>> at
>>> org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
>>> at
>>> org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:667)
>>> at
>>> org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:423)
>>> at
>>> org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:326)
>>> at
>>> org.nick.resttester.RestTester.sendPostRequest(RestTester.java:62)
>>> at org.nick.resttester.RestTester.main(RestTester.java:87)
>>> Java Result: 1
>>> BUILD SUCCESSFUL (total time: 1 second)
>>> ====================================================
>>>
>>>
>>> Below is the method that is causing the runtime error:
>>>
>>> ====================================================
>>> public String sendPostRequest() {
>>> JsonObject json = Json.createObjectBuilder().
>>> add("name", "sw-dev").
>>> build();
>>> String response = target.
>>> path("resource").
>>> path("account").
>>> path("group").
>>> request(MediaType.APPLICATION_JSON).
>>> post(Entity.json(json), String.class);
>>>
>>> return response;
>>> }
>>> ====================================================
>>>
>>> Is there a JAR missing that provides a MessageBodyWriter
>>> implementation? If there is where can I download it? Also is
>>> there a single JAR/Zip that contains the Java Docs for JSONP?
>> You need jsonp-jaxrs.jar. It can be downloaded at
>> http://search.maven.org/#artifactdetails%7Corg.glassfish%7Cjsonp-jaxrs%7C1.0%7Cbundle
>>
>> API Javadocs are at :
>> http://search.maven.org/#artifactdetails%7Cjavax.json%7Cjavax.json-api%7C1.0%7Cbundle
>>
>> Jitu
>>
>>
>
>