• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Jersey+Json Service

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't your produceJSON method return type of Response as in the other method?
 
bablu singh
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic