0
  CreateEmployeeJerseyClient client1=new CreateEmployeeJerseyClient();
  ClientResponse response=client1.findAll_XML(ClientResponse.class);

  GenericType<List<TblEmployee>> genericType = new GenericType<List<TblEmployee>>() {};
  List<TblEmployee> data= new ArrayList<TblEmployee>();
  data=(response.getEntity(genericType));
  Employee p=new Employee();
  p.setId(5);
  p.setFirstname("Johan");
  p.setLastname("Russel");
  p.setGender("Male");
  p.setAddress("sss");
  client1.create_XML(p);

When I implement this code in Java (JDK 1.8) to save data in MYSQL, it showing the error like "Method getEntity() in class ClientResponse cannot be applied to given types"

I referred these below links. https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/RESTfulWebServices_Part2/RESTfulWebservicesPart2.htm https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/RESTfulWebServices/RESTfulWebservices.htm

ab_404
  • 61
  • 7
  • The links you're referring to use Jersey 1.x while you're probably using Jersey 2.x or even Jersey 3.x. From Jersey 2.x on, there's no method getEntity() which could be applied to an instance of GenericType. You'll want to use [readEntity()](https://eclipse-ee4j.github.io/jersey.github.io/apidocs/2.22/jersey/javax/ws/rs/core/Response.html#readEntity(javax.ws.rs.core.GenericType)) instead. – Mihe Sep 13 '22 at 05:36
  • When I use readentity() method, it is showing error like Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/xml, type=class org.glassfish.jersey.client.ClientResponse, genericType=class org.glassfish.jersey.client.ClientResponse. at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:207). – ab_404 Sep 13 '22 at 06:07
  • 1
    So, the compilation error is gone, that is your first problem is solved. Now, you're faced with a runtime error which is a different story. Have a look at https://stackoverflow.com/questions/30754641/jersey-version-issue-messagebodyreader-not-found-for-media-type-application-xml – Mihe Sep 13 '22 at 06:16

0 Answers0