1

I have a RESTful web service application in java deployed on google app-engine which uses jersey 1.18.6. I want to use postmark java client to send transactional emails from it. When I integrated it, i was seeing the following exception:

javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family

From what I could find, I think this error was because of there were two different (and probably incompatible) version of jersey being used ,1.18.6 for jersey-server, jersey-guice and jersey-bundle and 2.25.1 for jersey-client (by postmark).

Then I tried to make the jersey version 1.18,6 throughout, so in the my main project pom, while including the dependency for postmark, I excluded the jersey-client (by added exclusions header) and separately added jersey-client dependency in my main project .

But then I got the following error:

java.lang.NoClassDefFoundError: javax/ws/rs/core/MultivaluedHashMap

This is I think the class MultivaluedHashMap is present only in jax-rs 2.x versions (which is compatible with jersey 2.x versions)

So my questions are:

  1. Is there a version of postmark java client library which uses jersey 1.x instead of jersey 2.x?

  2. If no then what options do I have other than migrating my main project from jersey 1.x to jersey 2.x. I don't want to do that since we will have to migrate not just the jersey dependencies but I think some other things like guice, shiro etc. which would be time consuming. Also it doesn't really seem optimal to modify multiple existing dependencies just to include one additional module.

Archit Sinha
  • 775
  • 1
  • 8
  • 33

3 Answers3

1

There isn't. The very first commit of the project's pom.xml already used Jersey 2.25.1

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • So is there any way I can use postmark in my project without having to update my dependencies to jersey 2.x? – Archit Sinha Jun 12 '18 at 05:45
  • 1
    One technique that's commonly used in such situation is Shading. It's a bit too broad to explain here, but try reading up about it: https://maven.apache.org/plugins/maven-shade-plugin/ – Mureinik Jun 12 '18 at 05:48
0

as Mureinik mentioned above, when we worked on the library, our plan at Postmark was to use newer library versions, since they are better options in long run.

On our Github page Rupert made good suggestions, from which I find separate ClassLoader a good choice. I will play a bit with the library code in next couple of days on compatibility, however we are always in favour of using newer libraries for our codebase.

ibalosh
  • 135
  • 6
0

please check out my latest comment on Github issues page for possible solution for using older Jersey version https://github.com/wildbit/postmark-java/issues/11

It should be pretty easy to port the library to Jersey 1.x by porting only the HttpClient class on your side.

ibalosh
  • 135
  • 6