title: @Resource not setting javax.ejb.TimerService
body: <p>I'm getting a NullPointerException when trying to create a Timer.  Obviously the TimerService is not getting set, but my question is, why? As far as I can tell I'm following the exact pattern used by another class in our application that <em>does</em> work.  </p>
  
  <p><strong>Note</strong>: I'm new to EJB so explanation is helpful</p>
  
  <pre><code>@Stateless
  public class MyClass implements SomeInterface
  {
     private static final Logger ourLogger = new Logger(MyClass.class);
  
     private volatile Timer timer = null;
     private volatile static MyClass instance = null;
  
     @javax.annotation.Resource
     TimerService timerService;
  
  
     @Override
     public synchronized void myMethod()
     {
        resetTimer();
        //do other stuff
     }
  
  
     /**
      * Creates the timer.
      */
     @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
     private synchronized void resetTimer()
     {
        if (timer != null)
        {
           timer.cancel();
           timer = null;
        }
        //NullPointerException on next line:
        timer = timerService.createTimer(30000, "My Note");
     }
  
     public static MyClass getInstance()
     {//MDB calls this, then runs instance.myMethod
        if (instance == null)
        {
           instance = new MyClass ();
        }
  
        return instance;
     }
  
  
     @Timeout
     public synchronized void timeout()
     {
         //Do some stuff
         instance = null;
     }
  
  }
  </code></pre>