Reputation: 643
I keep reading in all sorts of Java libraries, which are using the Jersey HTTP client package, that I should be careful because they use Jersey 2.x and if I have Jersey 1.x in my classpath already, it may cause some conflicts.
But, Jersey project changed group id and package names when it was incorporated into Glassfish project, starting with version 2.x.
Since package names are different, what conflicts could there be? If I have Jersey 1.x in my deployable, those classes will be used, because of Jersey 2.x, provided by the Glassfish Runtime, are entirely different classes, with different names.
Likewise, if I have Jersey 1.x in my deployable, and some dependency comes and adds Jersey 2.x, the only problem that I may have is the following: without a deployment descriptor, Glassfish will use its version of the library, not the provided one. But in any case, no problem should occur because I have both Jersey 1.x and 2.x in my classpath, right?
Please advise, am I missing something? What's all the fuss about?
Upvotes: 3
Views: 3526
Reputation: 1107
Yes you should !
Always think twise when your project is attached with dependency which is out of your control.
One is as you,ve mentioned from 1.x to 2.x they have moved from sun
namespace to glassfish
namespace.
And also in 1.x they use JEE6 version of JAX-RS and in 2.x they use JEE7 version of JAX-RS. This is a big deal. For example javax.ws.rs.core.Application
used in jersey in differen versions are different and cannot used in the same manner.
Jesey 2.x uses JEE 7. In JEE 7 version of javax.ws.rs.core.Application
has
getClasses()
getSingletons()
getProperties()
methods defined. https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Application.htmlJesey 1.x uses JEE 6. In JEE 6 version of javax.ws.rs.core.Application
only has
getClasses()
getClass()
But getProperties()
is not defined. https://jersey.github.io/apidocs/1.19.1/jersey/javax/ws/rs/core/Application.html
Which can lead to erros like NoSuchMethodError
https://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodError.html
This is just one incompetency. Im sure if you,ve dig deeper you can find more.
Its not only the namespaces, the underlying implementations has changed a log. Yes glassfish runtime is loaded with jersey. But you may be in trouble because although have specified provided scope different artifact names can lead to inconsistencies.
Upvotes: 2