Product version - 10.4.0 Product type (Angular or MVC)?Angular Product framework type (.net framework or .net core)? .NetCore ABP Framework version? ABP 6.4
Hi Support team,
Getting the following exception in Integration Testing:
Castle.MicroKernel.ComponentActivator.ComponentActivatorException: 'ComponentActivator: could not instantiate Hangfire.BackgroundJobClient' Inner Exception: InvalidOperationException: JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
My Test class:
[DependsOn(typeof(BackgroundJobClient))]
public class MyTest : AppTestBase
{
private readonly IMyAppService _myAppService;
public MyTest()
{
_myAppService = Resolve<IMyAppService>();// Exception here
}
}
My App service:
public class MyAppService : MyAppServiceBase, IMyAppService
{
private readonly IBackgroundJobClient _backgroundJobClient;
public MyAppService(IBackgroundJobClient backgroundJobClient)
{
_backgroundJobClient = backgroundJobClient;
}
public async Task<ResultDto> UpdateMyFile(UpdateMyFileInput input)
{
_backgroundJobClient.Enqueue<MyAppService>(x => x.UpdateMyFileInBackground(_secretBackgroundProcessKey, input, tenantId, userId));
}
}
Exception call stack is:
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.TryResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency, Object& value)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext)
at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, Arguments arguments, IReleasePolicy policy, Boolean ignoreParentContext)
at Castle.MicroKernel.DefaultKernel.Resolve(Type service, Arguments arguments)
at Castle.Windsor.WindsorContainer.Resolve[T]()
at Abp.TestBase.AbpIntegratedTestBase`1.Resolve[T]()
at My_Tests..ctor() in ...\MyAppHub\server\test\my.Tests\\My_Tests.cs:line 26
Inner exception is:
JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
Please help.
2 Answer(s)
-
0
Hi,
You can set it as shown here https://support.aspnetzero.com/QA/Questions/3753#answer-ea9753b4-e5d9-4289-bea6-7512cc2decb1
-
0
Hi @ismcagdas,
Thanks v much for your reply.
I saw this link before, but that suggestion didn't work, so I moved the required APIs to another service to resolve this issue for the time being. I will try your suggestion once again when I need to write tests on the Service which has Hangfire included.
Thanks v much once again.