docusign / docusign-esign-java-client

The Official Docusign Java Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://javadoc.io/doc/com.docusign/docusign-esign-java/latest/index.html
MIT License
104 stars 95 forks source link

Dependency conflict: jakarta/ws/rs/ext/ContextResolver #269

Closed jonathanhenri closed 8 months ago

jonathanhenri commented 9 months ago

Hello. I work at a company that is trying to integrate docuSign internally but we are having dependency problems. There are several related to javax/jakarta/jersey.

The last log we have is this: 2023-10-19T18:43:47.732-03:00 DEBUG 26240 --- [nio-8080-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [jakarta.servlet.ServletException: Handler dispatch failed : java.lang.NoClassDefFoundError: jakarta/ws/rs/ext/ContextResolver]

My project uses Java 18 and Spring boot. The error happens when initializing (ApiClient apiClient = new ApiClient();) With or without url pom.txt

I added the project pom.xml.

I'm using the version:

<dependency>
    <groupId>com.docusign</groupId>
    <artifactId>docusign-esign-java</artifactId>
    <version>4.4.0</version>
</dependency>

However, I have already tried several others.

As solutions I have already tried the following dependencies:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
</dependency>
<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.28</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.inject</groupId>
    <artifactId>jersey-hk2</artifactId>
    <version>2.28</version>
</dependency>
<dependency>
    <groupId>com.unboundid.product.scim2</groupId>
    <artifactId>scim2-sdk-client</artifactId>
    <version>2.3.6</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
    <version>2.21</version>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-server</artifactId>
    <version>2.21</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.jaxrs</groupId>
    <artifactId>jackson-jaxrs-json-provider</artifactId>
    <version>2.2.3</version>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.21</version>
</dependency>

<dependency>
    <groupId>org.glassfish.jersey.bundles</groupId>
    <artifactId>jaxrs-ri</artifactId>
    <version>2.21</version>
</dependency>

I also tried:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>javax.ws.rs</groupId>
                <artifactId>jsr311-api</artifactId>
                <version>1.1.1</version>
            </dependency>
            <dependency>
                <groupId>javax.ws.rs</groupId>
                <artifactId>javax.ws.rs-api</artifactId>
<!--                <version>2.0-m01</version>-->
                <version>2.0</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.core</groupId>
                <artifactId>jersey-client</artifactId>
                <version>2.29.1</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.core</groupId>
                <artifactId>jersey-common</artifactId>
                <version>2.29.1</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.inject</groupId>
                <artifactId>jersey-hk2</artifactId>
                <version>2.29.1</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-multipart</artifactId>
                <version>2.29.1</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-json-jackson</artifactId>
                <version>2.29.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
AaronWDS commented 9 months ago

Hi Jonathan,

I've looked through our own pom.xml and see these are the dependencies we're using for jakarta for the eSignature SDK:

        <dependency>
            <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
            <artifactId>jackson-jakarta-rs-base</artifactId>
            <version>2.14.2</version>
        </dependency>

        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <version>3.1.0</version>
        </dependency>

You can try importing a shaded version of the eSign sdk (creating an uber-jar and bundling the dependencies) like this:

<dependency>
    <groupId>com.docusign</groupId>
    <artifactId>docusign-esign-java</artifactId>
    <version>4.4.0</version>
    <classifier>shaded</classifier>
</dependency>

Also, feel free to review our preconfigured the Quickstart (code-examples-java launcher). It is using SpringBoot 2.5 and I see your pom provided has SpringBoot 3.0, but otherwise I would try running the eSignature sdk as a shaded dependency in your project first to see if anything changes. Hope this helps, let me know if you have any other questions or if this suggestion wasn't helpful.

jonathanhenri commented 9 months ago

Your solution worked for my problem. Thanks.

puuuudding commented 1 week ago

~~Hi Aaron, I tried to use the shaded version and it works fine. I understand that in shaded version the docusign lib will self includes all the deps it needs in its own package. But why using non-shaded version, the transitive dependencies will not be included in our project like other libraries does? I see that the pom file in docusign META-INF includes all the deps defined. But for the pom file used in our project, it only has two Junit test dependencies.~~

answer found in #261