This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 221637 - Difficulty getting Jersey to produce XML or JSON
Summary: Difficulty getting Jersey to produce XML or JSON
Status: RESOLVED INCOMPLETE
Alias: None
Product: webservices
Classification: Unclassified
Component: REST (show other bugs)
Version: 7.2
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-07 13:01 UTC by vincewebb
Modified: 2012-11-21 05:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vincewebb 2012-11-07 13:01:09 UTC
Hello
I'm trying to use Jersey
http://jersey.java.net/
for the first time. Jersey is the reference implementation of JAX-RS, which is for building RESTful web services in Java.

Using NetBeans and GlassFish, getting started was pretty straight forward, I was able to create a RESTful web service that produces html without much difficulty.

From what I have read it should be even less effort to make it produce either XML or JSON. Instead of writing code to produce my own HTML, Jersey should invoke JAXB to produce XML or JSON to represent a Java object which needs to be output. This is where I have got stuck.

Google shows large numbers of people suffering with the same exception:

======
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class
======

I've tried a couple of the suggestions but I'm still stuck with the same exception.

Some people suggest a need to write your own handling classes, I've not gone down that road because recent Jersey documentation suggests it all works with very little effort.

I've got around to thinking that although I am using the current version of NetBeans and the latest GlassFish, these may not be using 100% compatible versions of Jersey.

I'm using:

JDK 1.6.0_30 (From Oracle)

NetBeans 7.2 (Which includes Jersey jar files created 2011-06-24 however they have names which suggest a mysterious version 1.8 whatever that is?)

GlassFish 3.1.2.2 (Which includes Jersey 1.11 jar files created 2012-03-31)

The current version of Jersey appears to be 1.15 so the Jersey jar files supplied with NetBeans 7.2 which have 1.8 in the name are something of a mystery. I would guess they are some intermediate step on the way to Jersey version 2 but the age of them (2011-06-24) makes me doubt this.

Any suggestions ?
Comment 1 vincewebb 2012-11-07 15:13:54 UTC
I now see that in the sequence of Jersey releases, 1.8 came before 1.11 not after. That solves one mystery, silly me for doing a text sort in my head. 1.8 vs 1.08 never mind.

The underlying issue remains, perhaps I should give NetBeans 7.3 beta a try.
Comment 2 vincewebb 2012-11-07 16:14:10 UTC
I tried NetBeans 7.3 beta, it comes with Jersey 1.13. Sadly the result is still the same exception:

javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class <my class>, and Java type class <my class>, and MIME media type application/json was not found
Comment 3 Denis Anisimov 2012-11-21 05:49:39 UTC
This is NB issuetracker. But I don't see from your description how
NB is involved in the your issue. It seems you have runtime issue with Jersey.
Jersey is separate product and has separate issue tracker.
Please provide detailed steps how do you use NB to face the issue.