I am trying to send JSON from POSTMAN to a RESTful web service. I followed this tutorial URL to send JSON through POSTMAN.
My URL:
HTTP: // local: 8080 / MyWebservice / rest / dataInsert / insert
My service method:
@POST
@Path("/insert")
@Consumes(MediaType.APPLICATION_JSON)
public String insertData(JSONObject jsonlist) throws UnknownHostException;
My impl:
@Override
public String insertData(JSONObject jsonlist) throws UnknownHostException {
System.out.println(jsonlist);
insertDataDao.insertData(jsonlist);
return "SUCCESS";
}
My DAO:
public String insertData(JSONObject jsonlist) throws UnknownHostException{
System.out.println(jsonlist);
MongoConnection mongoconnection = new MongoConnection();
MongoClient mongoclient = mongoconnection.getMongoClient();
MongoDatabase db = mongoclient.getDatabase("mydb");
MongoCollection<Document> col = db.getCollection("col");
String jsonString = jsonlist.toString();
System.out.println(jsonString);
Document doc = Document.parse(jsonString);
col.insertOne(doc);
System.out.println("Inserted Successfully !!!");
return "SUCCESS";
}
But I encounter the following exception:
JBWEB000236: Servlet.service () for the CXFServlet servlet generated an exception: java.lang.NoSuchMethodError: javax.ws.rs.InternalServerErrorException.validate (Ljavax / ws / rs / core / Response; status / core / Response; Lj $ $;) Ljavax / WS / RS / core / response;
I can not solve this problem. Can someone please help me regarding this ...