I have a domain class with @XMLRootElement annotation which will be return from the service.
My service is something like:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/GetProductList")
public Response getProductList(@QueryParam("Username") String username,
@QueryParam("Password") String password) {
CategoryResponse result = new CategoryResponse(returnDummyCategories());
return Response.ok().entity(result).build();
} catch (Exception e) {
log.error("Error fetching products.", e);
throw new WebApplicationException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
Also I have put the init parameter in the web.xml file:
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
As well I put the the code
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.owlike</groupId>
<artifactId>genson</artifactId>
<version>0.97</version>
</dependency>
in the pom.xml file.
But I still get exception following:
java.lang.NullPointerException
com.sun.jersey.spi.container.ContainerRequest.<init>(ContainerRequest.java:188)
com.sun.jersey.spi.container.servlet.WebComponent.createRequest(WebComponent.java:446)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:380)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
info.magnolia.cms.filters.ServletDispatchingFilter.doFilter(ServletDispatchingFilter.java:123)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.filters.CompositeFilter.doFilter(CompositeFilter.java:67)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.VirtualUriFilter.doFilter(VirtualUriFilter.java:70)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.module.cache.executor.Bypass.processCacheRequest(Bypass.java:58)
info.magnolia.module.cache.executor.CompositeExecutor.processCacheRequest(CompositeExecutor.java:66)
info.magnolia.module.cache.filter.CacheFilter.doFilter(CacheFilter.java:153)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.i18n.I18nContentSupportFilter.doFilter(I18nContentSupportFilter.java:76)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.RangeSupportFilter.doFilter(RangeSupportFilter.java:84)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.security.BaseSecurityFilter.doFilter(BaseSecurityFilter.java:60)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.security.SecurityCallbackFilter.doFilter(SecurityCallbackFilter.java:86)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.security.LogoutFilter.doFilter(LogoutFilter.java:93)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.module.templatingkit.filters.SiteMergeFilter.doFilter(SiteMergeFilter.java:97)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.MultiChannelFilter.doFilter(MultiChannelFilter.java:83)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.module.cache.filter.GZipFilter.doFilter(GZipFilter.java:75)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:85)
info.magnolia.cms.security.auth.login.LoginFilter.doFilter(LoginFilter.java:93)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.enterprise.registration.RegistrationFilter.doFilter(RegistrationFilter.java:52)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.UnicodeNormalizationFilter.doFilter(UnicodeNormalizationFilter.java:90)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.CosMultipartRequestFilter.doFilter(CosMultipartRequestFilter.java:91)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.module.devicedetection.filter.DeviceDetectionFilter.doFilter(DeviceDetectionFilter.java:73)
info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:61)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.ContentTypeFilter.doFilter(ContentTypeFilter.java:102)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.ContextFilter.doFilter(ContextFilter.java:131)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:83)
info.magnolia.cms.filters.CompositeFilter.doFilter(CompositeFilter.java:67)
info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:91)
info.magnolia.cms.filters.SafeDestroyMgnlFilterWrapper.doFilter(SafeDestroyMgnlFilterWrapper.java:108)
info.magnolia.cms.filters.MgnlFilterDispatcher.doDispatch(MgnlFilterDispatcher.java:67)
info.magnolia.cms.filters.MgnlMainFilter.doFilter(MgnlMainFilter.java:108)
info.magnolia.cms.filters.MgnlMainFilter.doFilter(MgnlMainFilter.java:94)
Can't find something wrong with the code and configuration.