title: NullPointerException at TaskScheduler
body: <p>I have a <strong>TaskScheduler class</strong> like this :</p>
  
  <pre><code>public class NotificationManger {
  
  @Autowired
  private TaskScheduler scheduler;
  
  private ScheduledFuture&lt;?&gt; sc;
  
  public NotificationManger(WebSocketMessage webSocketMessage, String userName, Date date, Date time) {
      scheduleTask(webSocketMessage, userName, combine(date,time));
  }
  
  public void scheduleTask(WebSocketMessage webSocketMessage, String userName, Date startTime) 
    { 
      Runnable r = new NotificationSenderTask(webSocketMessage, userName);
  
      sc = scheduler.schedule(r, new Date());//here I get a  NullPointerException 
  
     }
  }
  </code></pre>
  
  <p>and a <strong>Runnable class</strong> like this :</p>
  
  <pre><code>class NotificationSenderTask implements Runnable {
  
  @Autowired
  SimpMessagingTemplate webSocketMessageTemplate;
  
  private String userName;
  
  private WebSocketMessage webSocketMessage;
  
  public NotificationSenderTask(WebSocketMessage webSocketMessage, String userName) {
      this.webSocketMessage = webSocketMessage;
      this.userName = userName;
  }
  
  public void run() {
  
      webSocketMessageTemplate.convertAndSendToUser(userName, "/notification", webSocketMessage);;
  }
  
  }
  </code></pre>
  
  <p>and I call the <strong>TaskScheduler</strong> : <code>NotificationManger mn = new NotificationManger(new WebSocketMessage(n), user.getEmail(),date1,date2 );</code></p>
  
  <p>but I'm getting a <code>java.lang.NullPointerException: null</code> at <code>sc = scheduler.schedule(r, new Date());</code></p>
  
  <p>maybe I'm using the runnable class wrong.</p>
  
  <p>Any help will be appreciated, Thank you.</p>
  
  <p><strong>EDIT :</strong></p>
  
  <pre><code>@EnableWebMvc
  @EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true)
  @Configuration
  @ComponentScan(basePackages = "gestionprojet.java")
  @PropertySource("classpath:application.properties")
  @Import({PersistenceJPAConfig.class, WebSecurityConfig.class})
  public class WebConfig extends WebMvcConfigurerAdapter {...}
  </code></pre>