users@jersey.java.net

[Jersey] Singletons confusion

From: Jordan Zimmerman <jzimmerman_at_netflix.com>
Date: Tue, 27 Mar 2012 19:25:55 +0000

I have a class ala:

@Provider
        public class UIContext implements ContextResolver<UIContext>
        {
            @Override
            public UIContext getContext(Class<?> type)
            {
                return this;
            }
        }

I set it as a singleton in the ResourceConfig ala:

config.getSingletons().addAll(getSingletons(context));

However, in Jersey 1.9.1 I still get an exception that implies Jersey is trying to construct the object:

SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for constructor public com.netflix.exhibitor.core.rest.UIContext(com.netflix.exhibitor.core.Exhibitor) at parameter index 0