Thanks Jan, good to know.
How do you recommend implementing these seemingly conflicting requirements then?
- reusing Client instances
- supplying service-specific auth credentials to different services
Martynas
On Sun, Jan 4, 2026 at 7:52 PM Jan Supol <jan.supol@xxxxxxxxxx> wrote:
>
> Hi Martynas,
> Yes, this is still the same. When a WebTarget instance gets initialized - before the request, a costly injection framework (HK2) instance is created. Each feature is registered into the injection framework and to ensure the separation of features between
the WebTarget instances, a new WebTarget needs a new injection framework instance. That's where the time is spent.
> HTH,
> Jan
>
> Confidential- Oracle Internal
> ________________________________
> From: jersey-dev <jersey-dev-bounces@xxxxxxxxxxx> on behalf of Martynas Jusevičius via jersey-dev <jersey-dev@xxxxxxxxxxx>
> Sent: Sunday, December 28, 2025 8:35 PM
> To: jersey developer discussions <jersey-dev@xxxxxxxxxxx>
> Cc: Martynas Jusevičius <martynas@xxxxxxxxxxxxx>
> Subject: [External] : [jersey-dev] How To Use Jersey Client Efficiently
>
> Hi,
>
> There was this article from 2015 by Jakub Podlesak called How To Use
> Jersey Client Efficiently.
> It's gone from the Oracle site but can be found on the Wayback Machine:
>
https://urldefense.com/v3/__https://web.archive.org/web/20210420010938/https:/*blogs.oracle.com/japod/how-to-use-jersey-client-efficiently__;Lw!!ACWV5N9M2RV99hQ!IL5I1_uKkYpaJ5ory5lAu-oSbdP02kJBwE6QTWJ7afqzdKSXIZkdvhTT-Um2fTZ0am93fi3_axsS7EovaW3Ptg$
>
> It says this about the 2.x Client API:
> "Be careful when touching configuration of a web target!. What does it
> mean? Whenever you create a new web target with updated configuration,
> Jersey will effectively create a new client runtime. To keep your
> application performing well, you should think of reusing all such web
> targets."
>
> Is this still the case using Jersey 3.x? Or is it fine to register
> features directly on WebTargets?
>
> Currently I am reusing the same Client instance to access multiple
> different APIs.
> However those APIs may require different features, e.g.
> HttpAuthenticationFeature.
> What is the standard solution here - use a Client per API or just
> register the features on WebTarget? Maybe behind the scenes it's
> effectively the same?
>
> Thanks.
>
> Martynas
> atomgraph.com
> _______________________________________________
> jersey-dev mailing list
> jersey-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit
https://urldefense.com/v3/__https://www.eclipse.org/mailman/listinfo/jersey-dev__;!!ACWV5N9M2RV99hQ!IL5I1_uKkYpaJ5ory5lAu-oSbdP02kJBwE6QTWJ7afqzdKSXIZkdvhTT-Um2fTZ0am93fi3_axsS7Eqvo1uGYA$