• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Jersey+Json Service

 
bablu singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I am using get and post method with mime media type Json. Here is my JerseyService class.



Student class:


Web.xml:


When I hit the URL http://localhost:8080/RESTfullWS/rest/jsonServices/print
I am getting the exception:


Appreciate for suggestions ..
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't your produceJSON method return type of Response as in the other method?
 
bablu singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am following https://jersey.java.net/documentation/1.18/json.html. http://www.mkyong.com/webservices/jax-rs/json-example-with-jersey-jackson/.

I have got all jersey-client, core, json, server, servlet, 1.18, asm-3.1, jsr311-api-1.1.1.jars.

It should return output in json format, but no idea what I am missing.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't recall which libraries JAX-RS 1.0 (and Jersey 1.x) needs, but I would advise to follow a tutorial that uses JAX-RS 2.0 and Jersey 2.x rather than the obsolete 1.x version.
 
bablu singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using JAX-RS 2.0 and Jersey 2.x. I have got following jars in my library:

asm-all-repackaged-2.2.0-b14.jar, cglib-2.2.0-b14.jar, guava-14.0.1.jar, hk2-api-2.2.0-b14.jar, hk2-locator-2.2.0-b14.jar, hk2-utils-2.2.0-b14.jar, javax.annotation-api-1.2.jar, javax.inject-2.2.0-b14.jar, javax.ws.rs-api-2.0.jar, jersey-client-2.2.jar, jersey-common-2.2.jar, jersey-container-servlet-core-2.2.jar, jersey-server-2.2.jar, osgi-resource-locator-1.0.1.jar, validation-api-1.1.0.final.jar.

web.xml:


Following tutorial from https://jersey.java.net/documentation/latest/. https://jersey.java.net/documentation/latest/media.html.

Rest of the code is same. But the problem still persist. Getting the same exception. Any Idea??

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSON support in Jersey 2 is provided by the Jackson library - there should be several jar files named "jackson-something-or-other.jar". (I have 5 in my installation, but I suppose that number could fluctuate between releases.)
 
bablu singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, you Rock...!!!

You hit the nail on the head. It means jackson jars are required for json support.
Thanks very much..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!