Getting Quartz.Simpl.JsonObjectSerializer error while trying to use Quartz.NET with oWin
Asked Answered
C

1

6

I am receiving the following error while I try to call a controller on my project which uses oWin and Quartz.Net 3.0.7 with Autofac .

{
"Message": "An error has occurred.",
"ExceptionMessage": "An error occurred when trying to create a controller of type 'QuartzController'. Make sure that the controller has a parameterless public constructor.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": "   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "An exception was thrown while activating Chatech.Quartz.Owin.Controllers.QuartzController -> Chatech.Quartz.Owin.Application.JobInformation.JobInformationService -> λ:Quartz.IScheduler.",
"ExceptionType": "Autofac.Core.DependencyResolutionException",
"StackTrace": "   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget) in C:\\projects\\autofac\\src\\Autofac\\Core\\Resolving\\InstanceLookup.cs:line 135\r\n   at Autofac.Core.Resolving.InstanceLookup.Execute() in C:\\projects\\autofac\\src\\Autofac\\Core\\Resolving\\InstanceLookup.cs:line 83\r\n   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in C:\\projects\\autofac\\src\\Autofac\\Core\\Resolving\\ResolveOperation.cs:line 131\r\n   at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) in C:\\projects\\autofac\\src\\Autofac\\Core\\Resolving\\ResolveOperation.cs:line 93\r\n   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) in C:\\projects\\autofac\\src\\Autofac\\ResolutionExtensions.cs:line 1041\r\n   at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters) in C:\\projects\\autofac\\src\\Autofac\\ResolutionExtensions.cs:line 814\r\n   at Autofac.Integration.WebApi.AutofacWebApiDependencyScope.GetService(Type serviceType)\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Object serializer type 'Quartz.Simpl.JsonObjectSerializer, Quartz.Serialization.Json' could not be instantiated.",
"ExceptionType": "Quartz.SchedulerException",
"StackTrace": "   at Quartz.Impl.StdSchedulerFactory.<Instantiate>d__65.MoveNext() in C:\\projects\\quartznet\\src\\Quartz\\Impl\\StdSchedulerFactory.cs:line 666\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Quartz.Impl.StdSchedulerFactory.<GetScheduler>d__69.MoveNext() in C:\\projects\\quartznet\\src\\Quartz\\Impl\\StdSchedulerFactory.cs:line 1114\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Autofac.Extras.Quartz.QuartzAutofacFactoryModule.<>c.<Load>b__8_2(IComponentContext c) in C:\\work\\autofac.extras.quartz\\src\\Autofac.Extras.Quartz\\QuartzAutofacFactoryModule.cs:line 90\r\n   at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass0_0`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) in C:\\projects\\autofac\\src\\Autofac\\Builder\\RegistrationBuilder.cs:line 62\r\n   at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in C:\\projects\\autofac\\src\\Autofac\\Core\\Activators\\Delegate\\DelegateActivator.cs:line 72\r\n   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget) in C:\\projects\\autofac\\src\\Autofac\\Core\\Resolving\\InstanceLookup.cs:line 117",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Could not load type 'Quartz.Simpl.JsonObjectSerializer, Quartz.Serialization.Json'",
"ExceptionType": "System.TypeLoadException",
"StackTrace": "   at Quartz.Simpl.SimpleTypeLoadHelper.LoadType(String name) in C:\\projects\\quartznet\\src\\Quartz\\Simpl\\SimpleTypeLoadHelper.cs:line 58\r\n   at Quartz.Impl.StdSchedulerFactory.<Instantiate>d__65.MoveNext() in C:\\projects\\quartznet\\src\\Quartz\\Impl\\StdSchedulerFactory.cs:line 653"
}
}
}
}

I have the following code that initializes Quartz.Net

var schedulerConfig = new NameValueCollection
{
    {"quartz.serializer.type", "json"},
    {"quartz.scheduler.instanceName", "Main Quartz Job Scheduler"},
    {"quartz.scheduler.instanceId", "QuartzAdmin"},
};

containerBuilder.RegisterModule(new QuartzAutofacFactoryModule
{
    ConfigurationProvider = c => schedulerConfig
});

If I comment {"quartz.serializer.type", "json"}, everything works fine. I have referenced Quartz.Serialization.Json and I see that is being copied to the bin\Debug folder. What is the issue here?

Comfort answered 9/11, 2019 at 7:12 Comment(1)
Any quartz.net expert out there?Comfort
C
12

There is a separate Quartz.Serialization.Json package that you need to install to use the json serializer.

Cook answered 4/12, 2019 at 16:10 Comment(1)
Installing Quartz.Serialization.Json package works for me.Basuto

© 2022 - 2024 — McMap. All rights reserved.