Base solution for your next web application
Open Closed

Getting the exception - Castle.MicroKernel.ComponentActivator.ComponentActivatorException: 'ComponentActivator: could not instantiate Hangfire.BackgroundJobClient' #10714


User avatar
0
bluescopesteel created

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)