Running into java.lang.NoClassDefFoundError: class com.sun.jersey.core.header.MediaTypes while using the Docusign Java Client

萝らか妹 提交于 2019-12-12 04:03:44

问题


I am new to Docusign and trying to use the Java Client However I run into the following error when trying to use code from the recipes -

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.jersey.core.header.MediaTypes
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:182)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
at com.sun.jersey.api.client.Client.init(Client.java:343)
at com.sun.jersey.api.client.Client.access$000(Client.java:119)
at com.sun.jersey.api.client.Client$1.f(Client.java:192)
at com.sun.jersey.api.client.Client$1.f(Client.java:188)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.api.client.Client.<init>(Client.java:188)
at com.sun.jersey.api.client.Client.<init>(Client.java:160)
at com.sun.jersey.api.client.Client.create(Client.java:673)
at com.docusign.esign.client.ApiClient.getClient(ApiClient.java:671)
at com.docusign.esign.client.ApiClient.getAPIResponse(ApiClient.java:429)
at com.docusign.esign.client.ApiClient.invokeAPI(ApiClient.java:543)
at com.docusign.esign.api.AuthenticationApi.login(AuthenticationApi.java:147)

The jars that I included to resolve some dependency issues are -

com.fasterxml.jackson.core/jars/jackson-annotations-2.4.2.jar
com.fasterxml.jackson.core/jars/jackson-core-2.4.2.jar
com.fasterxml.jackson.core/jars/jackson-databind-2.4.2.jar
com.fasterxml.jackson.datatype/jars/jackson-datatype-joda-2.1.5.jar
io.swagger/jars/swagger-annotations-1.5.4.jar
com.sun.jersey.contribs/jars/jersey-multipart-1.18.jar
com.sun.jersey/jars/jersey-bundle-1.19.jar
com.brsanthu/jars/migbase64-2.2.jar
com.docusign.esign/jars/com-docusign-esign-15.4.0.jar

回答1:


You don't have jersey-core jar. You can download the jar from here




回答2:


Adding javax.ws.rs-api-2.0.1.jar resolved my NoClassDefFoundError. This jar does not get listed in the maven dependency tree. A Junit test for the com.sun.jersey.core.header.MediaTypes class as shown below helped me get a descriptive error message.

public class MediaTypesTest extends TestCase {

    public void testLoadClass() throws Exception {
        MediaTypes.getTypeWildCart(MediaType.MULTIPART_FORM_DATA_TYPE);

    }
}



回答3:


First of all welcome to DocuSign community! I am sorry to hear that you have dependency issues. I will glad to help you to fix it.

In order to make DocuSign Java developers life easier, we have published a brand new Maven package. Please go to this page and you will find all the information that you need, in order to get up and running with the Java client: http://mvnrepository.com/artifact/com.docusign/docusign-esign-java/2.0.0.

As you will see, the jersey-client and jersey-multipart version is 1.18.

If you are using Pom, Gradle, or any other build system that supports remote package dependency resolving, then you can drop the packages that are in your lib folder, and use the Maven package. Your build management software (Pom or Gradle), will be able to resolve the dependencies automagically.

  • For Pom:

<dependency>
	<groupId>com.docusign</groupId>
	<artifactId>docusign-esign-java</artifactId>
	<version>2.0.0</version>
</dependency>
  • For Gradle: 'com.docusign:docusign-esign-java:2.0.0'

If you still have trouble, please let me know how you added the dependencies to your Java project and I will be glad to help.

Cheers,

Majid



来源:https://stackoverflow.com/questions/34868097/running-into-java-lang-noclassdeffounderror-class-com-sun-jersey-core-header-me

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!