'Do I need the "jersey-client" dependency on server side to support clients implemented with it?

I am implementing a RESTful server with Jersey and I am currently struggling to set up my maven dependencies correctly. I use an Apache Tomcat as the servlet container. According to the documentation I need to include the jersey-client dependency only when I am using the JAX-RS Client.

The way I understand that, is that I need to include the client dependency in my server side application to support clients developed with jersey. Is that correct?

Or is it meant in the way, that the client dependency is actually only needed in the client application?



Solution 1:[1]

The Jersey client is solely meant to be used as an HTTP client to make requests to other remote servers. That's it. You only need the client if you need to make requests to remote servers from inside your server application. The client should already be automatically pulled in by the server dependencies though. Whether or not some other client is using the Jersey client has no bearing on whether or not you need to include the Jersey client dependency in your Jersey server app.

Solution 2:[2]

While one indeed doesn't need jersey-client on the Server side application, please pay attention that it is a dependency of the jersey-container-servlet, as mentioned in the accepted answer.

In fact, if you'd try to exclude jersey-client transitively, the app won't start, but fail on class (ClientConfig something) not found exception, so don't.

Observed as of 2022-03 (Jersey v3.0.4)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul Samsotha
Solution 2 GullerYA