I have written a RESTful Client using Jersey 2.15 and invoking IBM Watson's RankRetrieve(R&R) Service. The code snippet works out of Eclipse environment as well as a WAR deployed out of Tomcat 7 and fetches the result JSON from the R&R service
HttpAuthenticationFeature basicAuthCredentials = HttpAuthenticationFeature.basic(this.userName, this.password);
Client client = ClientBuilder.newClient();
client.register(basicAuthCredentials);
WebTarget webTarget = client.target(this.buildUri())
.queryParam("ranker_id", this.rankerID)
.queryParam("q", searchTerm)
.queryParam("wt", "json");
Invocation.Builder invocationBuilder = webTarget.request(MediaType.TEXT_PLAIN_TYPE)
.accept(MediaType.APPLICATION_JSON);
Response response = invocationBuilder.get();
String resultString = response.readEntity(String.class);
System.out.println("RankRetrieve Response: " + resultString);
But when the same WAR file is deployed in Websphere LibertyProfile 8.5.5.7 the response received is 404.
{"responseHeader":{"status":400,"QTime":0},"error":{"msg":"Bad contentType for search handler :text/xml request={q=theQuestions&ranker_id=SomeRankerID&wt=json}","code":400}}
I then started searching about WLP & Jersey and came across articles such as JAX-RS Jersey Client on Websphere 8.5
Also during in Debug mode when I watch webTarget under Tomcat, I see the contents such as follows:
webTarget : JerseyWebTarget { https://<URL>?ranker_id=someRankerID&q=theQuestions&wt=json }
But the same watch under WLP shows me as follows:
webTarget : org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl@3e59a416
In the same application, in some other classes the Jersey Client also consumes other services and is working as expected under WLP, so I'm not able to figure out what is the reason only this code isn't working as expected under WLP.
This is my first Java project and I've tried searching online/reading SO/reading WLP documentation but none has helped me uncover what is the reason the same code is fetching me results under Tomcat and not under WLP.
I cannot remove WLP from our servers as it is extensively houses many other applications but any help in regards to the problem is appreciated.