title: how to fix problem scheduled tasks with spring boot
body: <p>My scheduled task is as follows
  But the application does not respond  when i use <code>@Scheduled(cron="0 46 17  * * *")</code>
  And when I use  <code>@Scheduled(fixedRate = 50000)</code> , When saving information on mongoDB The program gives an error</p>
  
  <p><code>[ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task.</code></p>
  
  <p><code>: An unexpected error occurred during scheduled work.</code>
  <code>java.lang.NullPointerException</code></p>
  
  <p>please help me for fix my cod . </p>
  
  <pre class="lang-java prettyprint-override"><code>
      @Scheduled(cron="0 46 17  * * *")
  //  @Scheduled(fixedRate = 5000)
      @RequestMapping("/closeAttendance}")
      public void cloceAttendance() {
          System.out.println("-1");
          AttendanceService attendanceService=new AttendanceService();
          Date date=attendanceService.getCurrentDate();
          System.out.println("1");
          List&lt;Attendance&gt; attendances=arepo.findByDate(date);
  if(attendances!=null) {
          System.out.println("attendances"+attendances.size());
          System.out.println("2");
  //  
          for(Attendance attendance:attendances) {
              System.out.println("3");
              attendance=attendanceService.closeAttendance(attendance);
              System.out.println("4");
              System.out.println("attendance"+attendance.getDate()+" "+ attendance.getPerson());
  //          arepo.save(attendance);
  
          }   
  
      }
  }
  </code></pre>