I use java ee 7
on Glassfish 4.1.1
. There is a rest service written in C#
and it returns a collection of Book instances.
The code on the rest client side which send get request:
public List<Bandwcorpus> downloadBandWCorpus(String corpus) {
Client restClient = ClientBuilder.newClient();
List<Bandwcorpus> ebooks=restClient
.target("http://bookandwalk.pl/api/admindocumentlist")
.queryParam("password", "XXXX").queryParam("corpusid", "YYYY")
.request(MediaType.APPLICATION_JSON)
.get(new GenericType<List<Book>>() {});
restClient.close();
return ebooks;
}
The Book class is a POJO:
public class Book {
private static final long serialVersionUID = 1L;
private Integer documentid;
private String corpusid;
private String corpusoriginalid;
private float nett;
private String currencyid;
private int vat;
private Discount discount;
private Upoluj isbn;
public Bandwcorpus() {
}
}
My applied get function is based on http://www.adam-bien.com/roller/abien/entry/jax_rs_returning_a_list blog post and this solution was applied also in Java ee 7 tutorial.
Unfortunately, I get the following compile error in this case:
error: no suitable method found for get(<anonymous com.fasterxml.classmate.GenericType<List<Book>>>)
List<Book> ebooks=restClient.target("http://bookandwalk.pl/api/admindocumentlist").queryParam("password", "XXXXX").queryParam("corpusid", "YYYYY").request(MediaType.APPLICATION_JSON).get(new GenericType<List<Book>>() {});
method SyncInvoker.<T#1>get(Class<T#1>) is not applicable
(cannot infer type-variable(s) T#1
(argument mismatch; <anonymous com.fasterxml.classmate.GenericType<List<Bandwcorpus>>> cannot be converted to Class<T#1>))
method SyncInvoker.<T#2>get(javax.ws.rs.core.GenericType<T#2>) is not applicable
(cannot infer type-variable(s) T#2
(argument mismatch; <anonymous com.fasterxml.classmate.GenericType<List<Book>>> cannot be converted to javax.ws.rs.core.GenericType<T#2>))
where T#1,T#2 are type-variables:
T#1 extends Object declared in method
<T#1>get(Class<T#1>)
T#2 extends Object declared in method
<T#2>get(javax.ws.rs.core.GenericType<T#2>)
Any idea what do I make wrong if this is the suggested way by Oracle and other experts?