users@jersey.java.net

[Jersey] 500 Internal server error while using xml mapper

From: abani behera <abani_at_kbase.in>
Date: Fri, 24 Jan 2014 22:05:16 +0530

Hi All,

I was trying write a simple restful service which exposes a POJO class to
XML or JSON format. Have used Jersey 2.5 library with Glassfish 4 and
Apache Tomcat 7.0.40.

the code snippet is as below.

*Pojo Class:*

*_at_XmlRootElement*
*public class Employee {*
*}*

*Application class:*



*_at_ApplicationPath("test")public class MyApplication extends ResourceConfig
{ public MyApplication() { packages("edu.rest.resources");
register(JacksonJaxbJsonProvider.class);
register(MoxyXmlFeature.class); }}*

*Service Class:*

@GET
@Produces({"application/xml","application/json"})
public Employee greet(){
return new Employee("Duke", "545");
}


When I use JacksonJaxbJsonProvider, my service produces proper JSON data
but when I user MoxyXmlFeature, the server throws 500 internal server error
and no other server logs.

I have seen this with GlassFish4 and Tomcat7.0.40.

Can anyone help me on this issue. Is there any specific configuration that
I am missing here.



Regards,
Abani