users@jersey.java.net

[Jersey] Re: class org.codehaus.jettison.json.JSONObject, and MIME media type, application/json, was not found

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Thu, 13 Jan 2011 09:59:59 -0800

Why are using JSONObject there? Just return User object -- no need to
wrap it with useless org.json stuff.

-+ Tatu +-

On Wed, Jan 12, 2011 at 8:38 PM, johny0704 <johnyse81_at_gmail.com> wrote:
>
> Hi I am returning JSONObject and getting the
>
> 23:35:57,890 SEVERE [ContainerResponse] A message body writer for Java type,
> class org.codehaus.jettison.json.JSONObject, and MIME media type,
> application/json, was not found
>
> Can you please help me on this.
>
> @GET
>        @Path("name/{ssoId}")
>        @Produces("application/json,application/xml")
>        public JSONObject getUser(@PathParam("ssoId") String ssoId) throws
> JSONException {
>                System.out.println(ssoId);
>                User user = new User();
>                user.setName("Jani");
>                user.setDesc("Hi");
>                return new JSONObject()
>        .put("name", user.getName())
>        .put("desc", user.getDesc());
>        }
>
> public class User implements Serializable {
>
>        private String name;
>        private String desc;
>        /**
>         * @return the name
>         */
>
>        public String getName() {
>                return name;
>        }
>        /**
>         * @param name the name to set
>         */
>        public void setName(String name) {
>                this.name = name;
>        }
>        /**
>         * @return the desc
>         */
>
>        public String getDesc() {
>                return desc;
>        }
>        /**
>         * @param desc the desc to set
>         */
>        public void setDesc(String desc) {
>                this.desc = desc;
>        }
> }
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/class-org-codehaus-jettison-json-JSONObject-and-MIME-media-type-application-json-was-not-found-tp5917106p5917106.html
> Sent from the Jersey mailing list archive at Nabble.com.
>