I'm having real hassle getting a quartz job in an application server to call a REST service - totally puzzled (:
I have quartz (v 2.2.2) deployed & working on an IBM Liberty Application Server (v 8.5.5.8) with Java 1.8 It scans a directory for files and then calls my Dummy Task.
However, when I replace the Dummy Task with a REST WebClient call - I get a pretty odd stacktrace.
java.lang.NullPointerException
[err] at com.ibm.ws.jaxrs20.client.bus.LibertyJAXRSClientBusFactory.getClientScopeBus(LibertyJAXRSClientBusFactory.java:89)
[err] at com.ibm.ws.jaxrs20.client.JAXRSClientImpl.target(JAXRSClientImpl.java:109)
[err] at org.apache.cxf.jaxrs.client.spec.ClientImpl.target(ClientImpl.java:100)
[err] at notification.server.rest.MyIBMHandler.testClient4(MyIBMHandler.java:61)
the last line is mine and the code I wrote is simply based on this: https://www.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_jaxrs2.0_clientconfig.html
When I googled the exception above, I didn't see much except for one stacktrace related one:- NullPointerException when running CXF JAX-RS 2.0 client "target" method in Liberty Profile under a Thread Which leads me to believe there may be some form of a threading conflict here.
To prove my REST client code was ok on my Liberty app-server, I did put my REST methodinto a servlet and call it there and it did work fine. i.e.
public void testClient4() {
javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder();
javax.ws.rs.client.Client c = cb.build();
String res = null;
try {
String resourceURL = "http://localhost:9080/SampleRest/sample/";
res = c.target(resourceURL).path("Greeting").request().get(String.class);
System.out.println("res:" + res);
} catch (Exception e) {
res = "[Error]:" + e.toString();
System.err.println("error:" + e.getMessage());
e.printStackTrace();
} finally {
if (c != null)
c.close();
System.out.println("res:" + res);
}
}
My Quartz props are close to out of the box, here is the threadpool section:-
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 4
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
My job class uses the annotation - @DisallowConcurrentExecution
I'm using the jersey 2.17 libs & jackson libs I've added lots of features to my Liberty profile - i.e.
<featureManager>
<feature>jsp-2.3</feature>
<feature>jaxrs-2.0</feature>
<feature>servlet-3.1</feature>
<feature>apiDiscovery-1.0</feature>
<feature>jaxrsClient-2.0</feature>
</featureManager>
For now, the REST service being called is a simple one. When running quartz within an app-server, do I need to do anyconfig to be able to call a REST service? - anyone got this working?
It appears we fixed this NPE in the latest Liberty fixpack, looking here, the 8.5.5.9 fixpack is planned to be available on March 18. Once released, please test and determine if it fixes this problem, and if not let us know.