The problem is that whenever I try to produce response of media type anything other than JSON, I get "MessageBodyWriter" not found error.
But the response works fine for Application_JSON outputs.
I am using several dependencies in my Maven POM so maybe MessageBodyWriter is getting overridden or maybe only for JSON its included.
Here are the pom dependencies -
org.postgresql
postgresql
9.2-1003-jdbc4
mysql
mysql-connector-java
5.1.25
javax.ws.rs
javax.ws.rs-api
2.0
javax.servlet
javax.servlet-api
3.0.1
provided
org.glassfish.jersey.core
jersey-client
2.22.1
org.glassfish.jersey.containers
jersey-container-servlet
2.22.1
org.glassfish.jersey.media
jersey-media-moxy
2.22.1
org.glassfish.jersey.media
jersey-media-multipart
2.15
org.glassfish.jersey.media
jersey-media-sse
2.15
org.glassfish.jersey.media
jersey-media-jaxb
2.17
org.glassfish.jersey.ext
jersey-mvc
2.5.1
javax.ws.rs
jsr311-api
1.1.1
org.hibernate
hibernate-core
4.3.6.Final
javax.servlet.jsp
javax.servlet.jsp-api
2.3.1
provided
org.apache.commons
commons-dbcp2
2.0
org.codehaus.jackson
jackson-core-asl
1.9.0
org.codehaus.jackson
jackson-mapper-asl
1.9.0
com.owlike
genson
1.4
The sample Java class I am using is -
package com.va;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.server.mvc.Viewable;
@Path("orders")
public class OrderView{
@GET
@Produces(MediaType.TEXT_HTML)
public Viewable index() {
return new Viewable("index");
}
}
Also I have kept my index.htm file in webapp folder.
The config for web.xml is as -
Jersey REST Service
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.va
com.sun.jersey.api.json.POJOMappingFeature
true
com.sun.jersey.config.property.JSPTemplatesBasePath
/webapp
jersey.config.server.provider.classnames
org.glassfish.jersey.server.mvc.jsp.JspMvcFeature
com.sun.jersey.config.property.WebPageContentRegex
/(webapp)/.*
1
Jersey REST Service
/*
On accessing the URL localhost:8080/myapp/orders
I get HTTP 500 error and console error as
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=text/html, type=class org.glassfish.jersey.server.mvc.Viewable, genericType=class org.glassfish.jersey.server.mvc.Viewable.
Please guide me with what is the issue. Thanks in advance.:)