javajax-rscxflotus-dominols2j

How to get JAX RS 2 client working from Domino script library?


I need to call a REST API from LotusScript agent. I'm using LS2J so I have the Java code in script library.

I first tried with Jersey 2. First with latest version and then a few older Jersey 2 versions and was always getting an exception which was different in different versions but mostly ExceptionInInitializerError. I resolved dependencies first in Exclipse with Maven so I could import all the required jar files.

Then I decided to try with Apache CXF. I started with this in my pom:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-rs-client</artifactId>
    <version>3.2.7</version>
</dependency>

and imported all resolved JARs from Maven repository to Domino script library:

enter image description here

Code compiled fine but at runtime I'm getting this:

java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder

JAX RS related imports in the code are these:

import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;

Nothing refers to Jersey anywhere. In my understanding this means that it is not finding the CXF ClientBuilder implementation and exception shows the default implementation.

I got the REST client working with Jersey 1 but I hate to use a stone aged solution.

Any ideas?

Domino Designer and server versions are 10.


Solution

  • I removed all jars except javax.ws.rs-api-2.1.1.jar from script library and added all those jars to /jvm/lib/ext under domino installation. Then it started to work.

    For JSON processing I'm using Jackson and register the provider this way:

    client.register(new JacksonJsonProvider())
    

    I added Jackson jars only in the script library:

    enter image description here