title: Quarz schedule job throwing some errors
body: <p>I am having problem using Quarz for scheduling jobs in Java application based on Spring. Here is my custom Job:</p>
  
  <pre><code>import org.quartz.Job;
  import org.quartz.JobExecutionContext;
  import org.quartz.JobExecutionException;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import com.package.UserService;
  
  @Component
  public class ConnectionIntervalJob implements Job {
  
  @Autowired
  private UserService userService;
  
     public void execute(JobExecutionContext jExeCtx) throws     JobExecutionException {
         userService.calculateDelta();
     }
  }
  </code></pre>
  
  <p>My ConnectionScheduler class:</p>
  
  <pre><code>import org.quartz.JobBuilder;
  import org.quartz.JobDetail;
  import org.quartz.Scheduler;
  import org.quartz.SchedulerException;
  import org.quartz.SimpleScheduleBuilder;
  import org.quartz.Trigger;
  import org.quartz.TriggerBuilder;
  import org.quartz.impl.StdSchedulerFactory;
  
  public class ConnectionScheduler {
  public ConnectionScheduler() throws Exception {
      Scheduler scheduler = new StdSchedulerFactory().getScheduler();
      JobDetail job = JobBuilder
              .newJob(com.package.ConnectionIntervalJob.class)
              .withIdentity("job1" + (int)Math.floor(Math.random()*10) + 3 , "group1" +(int)Math.floor(Math.random()*10) + 3).build();
  
      Trigger trigger = TriggerBuilder
              .newTrigger()
              .withIdentity("trigger" +(int)Math.floor(Math.random()*10) + 3, "group1" +(int)Math.floor(Math.random()*10) + 3)
              .withSchedule(
                      SimpleScheduleBuilder.simpleSchedule()
                              .withIntervalInSeconds(20).withRepeatCount(5))
              .build();
      try {
          scheduler.start();
          scheduler.scheduleJob(job, trigger);
      } catch (SchedulerException e) {
          e.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>When I build my project using Apache Tomcat 7. The console logs some errors:</p>
  
  <pre><code>ERROR org.quartz.core.JobRunShell - Job group163.job163 threw an unhandled   Exception: 
  java.lang.NullPointerException
  at   com.package.jobs.ConnectionIntervalJob.execute(ConnectionIntervalJob.java:18)
  at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
  at      org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
  [DefaultQuartzScheduler_Worker-1] ERROR org.quartz.core.ErrorLogger - Job (group163.job163 threw an exception.
  org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
  at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
  at    org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
  Caused by: java.lang.NullPointerException
  at com.pakage.jobs.ConnectionIntervalJob.execute(ConnectionIntervalJob.java:18)
  at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
  ... 1 more
  </code></pre>
  
  <p>I suppose I am messing up something with the job name and the trigger name. Because of this I decided to generate a random int vale and add it to the group name and the trigger name but it did not work. I used the following link as a reference:
  <a href="http://www.quartz-scheduler.org/generated/2.2.1/html/qs-all/#page/Quartz_Scheduler_Documentation_Set%2Fco-use_instantiating_scheduler.html%23" rel="nofollow">quarz doc</a></p>
  
  <p>UPDATE:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt;
  
  &lt;!-- Database Configuration --&gt;
  &lt;import resource="DataSource.xml" /&gt;
  &lt;import resource="hibernate.xml" /&gt;
  &lt;bean class="com.package7.config.WebSocketConfig" /&gt;
  
  &lt;!-- Auto scan the components --&gt;
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="com.package1.entities" /&gt;
  &lt;context:component-scan base-package="com.package2.ving.controllers" /&gt;
  &lt;context:component-scan base-package="com.package3.dao" /&gt;
  &lt;context:component-scan base-package="com.package4.daoimpl" /&gt;
  &lt;context:component-scan base-package="com.package5.serviceimpl" /&gt;
  &lt;context:component-scan base-package="com.package6.jobs" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any help is appreciated! Thank you!</p>