users@jersey.java.net

[Jersey] Re: 500 Internal server error while using xml mapper

From: Andrzej Le¶kiewicz <andrzej.leskiewicz_at_gmail.com>
Date: Fri, 24 Jan 2014 18:09:23 +0100

Hi,
I don't think You need moxy for XML output. Jackson from version 2.0
supports XML as well. To use it, You need to use provider as specified on
Jackson tutorial, not in Jersey one as it depends on Jackson 1.9 (there is
a ticket for this already https://java.net/jira/browse/JERSEY-2107).

See https://github.com/FasterXML/jackson-jaxrs-providers for more info on
Jackson 2.0 provider .


As for missing log entry, there was a similar issue
https://java.net/jira/browse/JERSEY-2000 , but should be fixed in 2.3,
perhaps it is not.



2014/1/24 abani behera <abani_at_kbase.in>

> 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:*
>
>
>
> * @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
>



-- 
Z poważaniem
Andrzej Le¶kiewicz