I am working on a Blazor Server App using MudBlazor in .NET 8.0 application, then I decided to add Quartz.NET to handle some background jobs. I added the following packages to my project:
<PackageReference Include="Quartz" Version="3.13.1" /><PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.13.1" /><PackageReference Include="Quartz.Extensions.Hosting" Version="3.13.1" /><PackageReference Include="Quartz.Serialization.SystemTextJson" Version="3.13.1" />My Program.cs is configured as follows:
builder.Services.AddQuartz();builder.Services.AddQuartzHostedService(opt =>{ opt.WaitForJobsToComplete = true;});However, when I run the application in Linux (Ubuntu) as a Self-contained deployment (target runtime: linux-x64), using the follow command to run sudo nohup ~/apps/MySuperApp/MySuperApp --urls http://*:80 > MySuperApp.log, I encounter the following error:
fail: Microsoft.Extensions.Hosting.Internal.Host[11] Hosting failed to start Quartz.SchedulerException: ThreadPool type 'Quartz.Simpl.DefaultThreadPool' could not be instantiated. ---> System.ArgumentException: Cannot instantiate type which has no empty constructor (Parameter 'DefaultThreadPool') at Quartz.ExceptionHelper.ThrowArgumentException(String, String) at Quartz.Util.ObjectUtils.InstantiateType[T](Type) at Quartz.ServiceCollectionSchedulerFactory.InstantiateType[T](Type) at Quartz.Impl.StdSchedulerFactory.Instantiate() --- End of inner exception stack trace --- at Quartz.Impl.StdSchedulerFactory.Instantiate() at Quartz.Impl.StdSchedulerFactory.GetScheduler(CancellationToken ) at Quartz.ServiceCollectionSchedulerFactory.GetScheduler(CancellationToken ) at Quartz.QuartzHostedService.StartAsync(CancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token) at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1, CancellationToken, Boolean, Boolean, List`1, Func`3) [See nested exception: System.ArgumentException: Cannot instantiate type which has no empty constructor (Parameter 'DefaultThreadPool') at Quartz.ExceptionHelper.ThrowArgumentException(String, String) at Quartz.Util.ObjectUtils.InstantiateType[T](Type) at Quartz.ServiceCollectionSchedulerFactory.InstantiateType[T](Type) at Quartz.Impl.StdSchedulerFactory.Instantiate()]Unhandled exception. Quartz.SchedulerException: ThreadPool type 'Quartz.Simpl.DefaultThreadPool' could not be instantiated. ---> System.ArgumentException: Cannot instantiate type which has no empty constructor (Parameter 'DefaultThreadPool') at Quartz.ExceptionHelper.ThrowArgumentException(String, String) at Quartz.Util.ObjectUtils.InstantiateType[T](Type) at Quartz.ServiceCollectionSchedulerFactory.InstantiateType[T](Type) at Quartz.Impl.StdSchedulerFactory.Instantiate()ist`1, Func`3)Quartz.SchedulerException: ThreadPool type 'Quartz.Simpl.DefaultThreadPool' could not be instantiated.