title: Quartz Job exception
body: <p>I have sceheduled few quartz jobs and triggers for each job, and im using Database store to store the job details and i use simple triggers. I'm using Azure multiple instance. The jobs are scheduled properly, but sometimes the triggers are not firing and the trigger status is "error" and its an intermitent issue. In the console i see the exception as follows, </p>
  
  <blockquote>
    <p>A first chance exception of type 'System.ArgumentException' occurred in Quartz.dll<br>
    A first chance exception of type 'Quartz.SchedulerException' occurred in Quartz.dll<br>
    A first chance exception of type 'Quartz.SchedulerException' occurred in Quartz.dll</p>
  </blockquote>
  
  <p>Could anyone please help me solve the issue? Thanks</p>
  
  <p>EDIT:</p>
  
  <p>Im using ninject to open the Isession when the service starts as follows:</p>
  
  <blockquote>
    <p>private void InitService()
            {</p>
  </blockquote>
  
  <pre><code>        IKernel kernel = CreateKernel();
          _intraClockAuctionService = kernel.Get&lt;IIntraClockAuctionService&gt;();
      }
  </code></pre>
  
  <blockquote>
    <p>private IKernel CreateKernel()
            {
                var kernel = new StandardKernel();</p>
  </blockquote>
  
  <pre><code>        kernel.Bind&lt;ISessionFactory&gt;().ToProvider&lt;SessionFactoryBuilder&gt;().InSingletonScope();
          kernel.Bind&lt;ISession&gt;().ToMethod(context =&gt; context.Kernel.Get&lt;ISessionFactory&gt;().OpenSession())
              .InCallScope();
          kernel.Bind(typeof(IRepository&lt;&gt;)).To(typeof(Repository&lt;&gt;));
  
          kernel.Bind&lt;IJobFactory&gt;().To&lt;JobFactory&gt;();
          kernel.Bind&lt;Func&lt;Type, IJob&gt;&gt;().ToConstant(new Func&lt;Type, IJob&gt;(type =&gt; (IJob)kernel.Get(type)));
          kernel.Bind&lt;ISchedulerFactory&gt;().ToConstant(new StdSchedulerFactory(GetQuartzProperties()));
  
          kernel.Bind&lt;MembershipProvider&gt;().ToConstant(Membership.Providers["DefaultMembershipProvider"]);
          kernel.Bind&lt;IMembershipService&gt;().To&lt;AccountMembershipService&gt;();}
  </code></pre>
  
  <p>and i create my job class as follows:</p>
  
  <blockquote>
    <p>[DisallowConcurrentExecution]</p>
  </blockquote>
  
  <pre><code>public class AuctionActivateJob : IJob
  {
      private readonly ISession _session;
      private readonly IAuctionService _auctionService;
      private readonly JobManager _jobManager;
      private readonly List&lt;IScheduler&gt; _schedulers = new List&lt;IScheduler&gt;();
  
  
  
      public AuctionActivateJob(ISession session, JobManager jobManager, IAuctionService auctionService)
      {
          Utils.LogUtils.LogEvent("inside AuctionActivateJob");
          _session = session;
          _auctionService = auctionService;
          _jobManager = jobManager;
      }
  
      public void Execute(IJobExecutionContext context)
      {
          try
          {
              SessionTransaction.BeginTransation(_session);
              var auctionId = (int)context.MergedJobDataMap["AuctionId"];
              var auction = _auctionService.GetAuction(auctionId);
  
              LogUtils.LogEvent(auction.AuctionId + "_Activation starts:" + DateTime.Now);
  
              _auctionService.ActivationStart(auction.AuctionId);
  
              LogUtils.LogEvent(auction.AuctionId + "_Activation ends:" + DateTime.Now);
  
              SessionTransaction.CommitTrans(_session);
  
          }
          catch (Exception e)
          {
              LogUtils.LogException(e);
              Email.GenerateServiceExceptionEmail(e);
  
              if (_session.Transaction != null &amp;&amp; _session.Transaction.IsActive)
              {
                  _session.Transaction.Dispose();
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and i have common class to add job as </p>
  
  <p>public class JobManager</p>
  
  <pre><code>{
      private readonly IJobFactory _jobFactory;
  
      private readonly ISchedulerFactory _schedulerFactory;
  
  
      public JobManager(ISchedulerFactory schedulerFactory, IJobFactory jobFactory)
      {
          _schedulerFactory = schedulerFactory;
          _jobFactory = jobFactory;
      }
  
      public IScheduler Add&lt;T&gt;(ITrigger trigger) where T : IJob
      {
          string name = trigger.Key.Name;
          IScheduler scheduler = _schedulerFactory.GetScheduler();
          try
          {
              scheduler.JobFactory = _jobFactory;
              scheduler.Start();
              var jobName = typeof (T).Name + "_" + name;
              var jobDetail = new JobDetailImpl(jobName, typeof (T));
  
              var isScheduled = scheduler.CheckExists(new JobKey(jobName));
              Utils.LogUtils.LogEvent("isScheduled in quartz: " + isScheduled);
              if (isScheduled)
                  return null;
              scheduler.ScheduleJob(jobDetail, trigger);
          }
          catch (JobPersistenceException exception)
          {
              Utils.LogUtils.LogException(exception);
              return null;
              //do not do anything
          }
          catch (Exception ex)
          {
              Utils.LogUtils.LogException(ex);
              return null;  
          }
  
          return scheduler;
      }
  </code></pre>
  
  <blockquote>
    <p>public class AuctionManagementService : IAuctionManagementService
        {
            private static readonly TimeSpan SchedulePoolingInterval = 
    TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["SchedulePoolingInter
    val"]));</p>
  </blockquote>
  
  <pre><code>    private readonly string _appName = ConfigurationManager.AppSettings["AppName"];
      private readonly Timer _eventTimer;
      private readonly ISession _session;
      private readonly IAuctionService _auctionService;
      private readonly JobManager _jobManager;
      private readonly List&lt;IScheduler&gt; _schedulers = new List&lt;IScheduler&gt;();
      private readonly ISchedulerFactory _schedularFactory;
  
      public AuctionManagementService(ISession session, JobManager jobManager, IAuctionService auctionService, ISchedulerFactory schedulerFactory)
      {
  
          try
          {
              _session = session;
              _eventTimer = new Timer();
              _eventTimer.Elapsed += Refresh;
              _eventTimer.Interval = SchedulePoolingInterval.TotalMilliseconds;
              _jobManager = jobManager;
              _auctionService = auctionService;
  
              _schedularFactory = schedulerFactory;
  
              _schedulers.Add(_schedularFactory.GetScheduler());
          }
          catch (Exception ex)
          {
              LogUtils.LogEvent(ex.Message + ex.StackTrace);
              Utils.Email.GenerateServiceExceptionEmail(ex);
          }
  
      }
  </code></pre>