hello hosting restful webservice via inbuilt jax-rs of websphere.everything seems good.but when try return json response throws error unsupported media type 415. after spending time on found
<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 added server.xml of server.i have opened server.xml , added snippet near last tag 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 - 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 add snippet , how?please me out of this.
thank you
my issue got resolved removing
@consumes(mediatype.application_json)
from class.
Comments
Post a Comment