restjerseyjax-rsjsrjsr311

jaxrs-api VS jsr311-api VS javax.ws.rs-api VS jersey-core VS jaxrs-ri


I have googled around quite a bit still am confused as to what each of the above exactly mean.

Here is my understanding of it:

I downloaded each jar and tried to decompile and see what is inside it, but I am only able to find interfaces in all of them and not the implementation.

I am facing these questions in the context of duplicate warnings generated by maven shade plugin, and need proper understanding of the above to figure out which ones to exclude and why.


Solution

  • I'll first get to the question

    "JSR311 it is a specification request. Which means it is supposed to be a document. Why then is it a jar?"

    Except the last (jersey-core), all those jars are "specification" jars. The JAX-RS (as well as many other Java) specifications define contracts (or interfaces) that implementators should implement the specified behavior for.

    So basically all the classes specified in the specification should be in the jar as contracts. End users of the jars can use them for the contracts. but there is no implementation. You need to have an actually implementation to run the application, though the spec API jar is enough to compile a complete JAX-RS compliant application.

    For example, if we have one of those spec API jars on the classpath, we can author an entire JAX-RS application and compile it, but in order to run it, if we don't have the actual implementation, we need to deploy to a server that has the actual implementation of that spec version, for example JBoss or Glassfish


    Other Resources

    Also note that though different implementation adhere to the spec, each implementation has its own set of extra features. To learn more you should go through the documentation of the different implementation. The three most popular implementations are Jersey, RESTeasy, and CXF