i'd like to have an singleton object in my Jersey 1.19.1 webservice, which is the same instance over all my Glassfish nodes. This is my current implementation:
@Singleton
@ApplicationScoped
@Stateless
public class ValueObject {
public long downloads = 0;
}
and
@Path("downloads")
public class Downloads {
@InjectParam
private ValueObject singleton;
}
The counter is increased when a file is downloaded. After downloading a file and asking for the downloadCounter 1 and 0 is returned depending on which of the two Glassfish nodes processed the request.
My goal is to get always 1. How can i achieve that?
Without @ApplicationScoped or using @Stateful instead of @Stateless leads to the same result.
Regards
John