title: java.util.ServiceLoader not loading my provider class
body: <p>I am trying to put together a basic SPI-based registry of Handlers, which I lookup from a HandlerRegistry.  When I use the ServiceLoader.load(Handler.class) to initialize the providers, and then iterate the list to lazily load them, I am not seeing any instances of the class.  Keeping this as simple as possible, my HandlerRegistry class is:</p>
  
  <pre><code>public class HandlerRegistry 
  {
    private static HandlerRegistry registry;
  
    private ServiceLoader&lt;Handler&gt; handlerLoader;
  
    private HandlerRegistry()
    {
      handlerLoader = ServiceLoader.load(Handler.class);
    }
  
    public static synchronized HandlerRegistry getRegistry()
    {
      if (registry == null) {
        registry = new HandlerRegistry();
        registry.init();
      }
      return registry;
    }
  
    private void init()
    {
  System.out.println("HandlerRegistry.init()");
    }
  
    public Handler lookup(String item)
    {
  System.out.println("lookup("+item+")");
      try {
        Iterator&lt;Handler&gt; it = handlerLoader.iterator();
        while (it.hasNext()) {
          Handler handler = it.next();
  System.out.println("found handler "+handler);
        }
      }
      catch (ServiceConfigurationError err) {
        err.printStackTrace();
      }
      return null;
    }
  }
  </code></pre>
  
  <p>I have a com.example.handler.Handler interface (empty for now for simplicity), and a com.example.handler.handlers.DummyHandler class which implements that interface.  I have created a file in my jar called META-INF/services/com.example.handler.Handler, which contains the single line</p>
  
  <pre><code>com.example.handler.handlers.DummyHandler
  </code></pre>
  
  <p>according to the javadoc.  My unit test simply calls the lookup() method to verify looking up the handler for an item.  Of course there will eventulaly need to be a check of some kind to see if this is the right handler for this item, but at this point I am not even seeing my DummyHandler class get loaded by the registry.  Am I doing something wrong here?</p>
  
  <p>Thanks!</p>