According to the documentation,
\"Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well
Your implementation is not thread-safe. When two threads access someMethod
at the same time they are sharing the same Client
and one will try to make a second request while the first one is not finished.
You have two choices:
Client
and WebTarget
manually.@javax.ejb.Singleton
which guarantees thread safety. (see chapter 4.8.5 of the EJB specification)If someMethod
in a container managed environment I would use the second approach.