users@jersey.java.net

Client API: Missing Dependency on Java Mail API?

From: Jorge L Williams <Jorge.Williams_at_inl.gov>
Date: Mon, 20 Oct 2008 13:34:56 -0600

Just FYI,

I looked here for guidance on dependencies when building a client
application:

https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/jersey/dependencies.html

The page suggested I add jersey-bundle.jar and jsr311-api.jar to my
classpath which I did. When running my app I received this error...

    [java] Exception in thread "main" java.lang.NoClassDefFoundError:
javax/mail/util/ByteArrayDataSource
     [java] at
com.sun.jersey.impl.provider.entity.DataSourceProvider.readFrom(DataSourceProvider.java:71)
     [java] at
com.sun.jersey.impl.provider.entity.DataSourceProvider.readFrom(DataSourceProvider.java:54)
     [java] at
com.sun.jersey.impl.client.urlconnection.URLConnectionClientHandler$URLConnectionResponse.getEntity(URLConnectionClientHandler.java:156)
     [java] at
com.sun.jersey.impl.client.urlconnection.URLConnectionClientHandler$URLConnectionResponse.getEntity(URLConnectionClientHandler.java:138)
     [java] at
com.sun.jersey.api.client.WebResource.handle(WebResource.java:466)
     [java] at
com.sun.jersey.api.client.WebResource.access$200(WebResource.java:64)
     [java] at
com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:404)

Adding the mail.jar from the Java MAIL API to my classpath resolved the
issue. I understand the dependency page states that java-mail should be
included when using MimeMultippart, but I didn't explicitly use this class
in my code. I simply requested a DataSource as output when making a POST
request.

-jOrGe W.