Hi Amareshwari,
this part of your web.xml doesn't seem right:
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xyz.MyApp</param-value>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.codehaus.jackson.jaxrs</param-value>
</init-param>
it should look like:
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xyz.MyApp</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.codehaus.jackson.jaxrs</param-value>
</init-param>
If it's just a typo in the mail, make sure you have Jackson libs on your
class-path or try add jersey-media-json-jackson module to your
application and register JacksonFeature to enable Jackson as your JSON
provider.
Michal
On 22.10.2013 06:52 , amar_nitw_at_yahoo.com wrote:
> Hello,
>
> I'm writing a simple web service, in which i have POJO with JAXB
> @XmlRootElement annotation. And I'm returning that on GET. XML output
> comes properly but JSON output fails with following exception :
>
> org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundExcept
> ion: MessageBodyWriter not found for media type=application/json,
> type=class com.inmobi.grill.api.QueryStatus, genericType=class
> com.inmobi.grill.api.QueryStatus.
> at
> org.glassfish.jersey.message.internal.WriterInterceptorExecutor$Termina
> lWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
> at
> org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed
> (WriterInterceptorExecutor.java:149)
> at
> org.glassfish.jersey.filter.LoggingFilter.aroundWriteTo(LoggingFilter.j
> ava:268)
> at
> org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed
> (WriterInterceptorExecutor.java:149)
> at
> org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundW
> riteTo(JsonWithPaddingInterceptor.java:103)
> at
> org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed
> (WriterInterceptorExecutor.java:149)
> at
> org.glassfish.jersey.server.internal.MappableExceptionWrapperIntercepto
> r.aroundWriteTo(MappableExceptionWrapperInterceptor.java:88)
> at
> org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed
> (WriterInterceptorExecutor.java:149)
> at
> org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(Messag
> eBodyFactory.java:1139)
> at
> org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(Serve
> rRuntime.java:562)
> at
> org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(Ser
> verRuntime.java:357)
> at
> org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRunti
> me.java:347)
> at
> org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)
> at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
> at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
> at
> org.glassfish.jersey.internal.Errors.process(Errors.java:315)
> at
> org.glassfish.jersey.internal.Errors.process(Errors.java:297)
> at
> org.glassfish.jersey.internal.Errors.process(Errors.java:267)
> at
> org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestSc
> ope.java:318)
> at
> org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:23
> 5)
> at
> org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandle
> r.java:983)
> at
> org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:359
> )
> at
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.
> java:372)
> at
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.
> java:335)
> at
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.
> java:218)
> at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
> at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHa
> ndler.java:1221)
> at
> com.inmobi.grill.query.service.AuthorizationFilter.doFilter(Authorizati
> onFilter.java:24)
>
> My setup is as follows :
> I'm starting the embedded jetty with 'mvn jetty:run' and servlet
> definition in web.xml :
>
> <servlet>
> <servlet-name>MyAPI</servlet-name>
>
> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-c
> lass>
> <init-param>
> <param-name>javax.ws.rs.Application</param-name>
> <param-value>com.xyz.MyApp</param-value>
>
> <param-name>jersey.config.server.provider.packages</param-name>
> <param-value>org.codehaus.jackson.jaxrs</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>MyAPI</servlet-name>
> <url-pattern>/myapi/*</url-pattern>
> </servlet-mapping>
>
> And MyApp definition:
>
> @ApplicationPath("/myapi")
> public class QueryApp extends Application {
> @Override
> public Set<Class<?>> getClasses() {
> final Set<Class<?>> classes = new HashSet<Class<?>>();
> // register root resource
> classes.add(MyResource.class);
> classes.add(MultiPartFeature.class);
> classes.add(LoggingFilter.class);
> return classes;
> }
> }
>
> Please let me know how i should solve this problem.
>
> Thanks
> Amareshwari