Hello all i am hosting a restful webservice via the inbuilt jax-rs of websphere.Everything seems good.But when i try to return a json response it throws an error unsupported media type 415. After spending some time on it i found that
<application
location="${server.config.dir}/dropins/my-war-SNAPSHOT.war"
id="mywar" name="mywar" type="war">
<classloader apiTypeVisibility="spec,ibm-api,api,third-party"/>
</application>
should be added to my server.xml of the server.I have just opened the server.xml and added the snippet near the last tag but the server crashed.
Client
@Path("/books")
@Consumes(MediaType.APPLICATION_JSON)
public class LibraryServiceImpl implements LibraryService {
private LibraryDAO libDao = new LibraryImpl();
@Path("/getbooks")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Response getBooks(@QueryParam("format") String format)
throws SQLException {
return Response.status(Status.OK).entity(new GenericEntity<List<Book>>(libDao.getAllBooks()) {}).build();
}
Web Xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Sample</display-name>
<servlet>
<description>
JAX-RS Tools Generated - Do not modify</description>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.nag.application.Config</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Where can i add that snippet and how?Please help me out of this.
Thank you