Hello, I am getting An internal error occcured : "ActivatorChain": "Castle.Proxies.EmploymentEducationAppServiceProxy" when trying to run swagger api. Earlier the solution was running fine. The only change i did was to change the class to collectiontype class.
I am attaching the screeshots below. Error Screen:
Collection Class: DTO declarataion:
Please let me know, what is wrong here.
12 Answer(s)
-
0
Share your application service please
-
0
Your issue may be related to mapper. Could you please check?
If the problem is not resolved please share the relevant logs, thank you.
-
0
Here is the code for application service.
using Microsoft.AspNetCore.Authorization; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Repositories; using ZW.EmpSvc.Employees; using ZW.EmpSvc.Permissions; using System.Linq.Dynamic.Core; namespace ZW.EmpSvc.EmploymentEducations { [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Default)] public class EmploymentEducationAppService : EmpSvcAppService, IEmploymentEducationAppService { private readonly IEmploymentEducationRepository _employmentEducationRepository; private readonly EmploymentEducationManager _employmentEducationManager; private readonly IEmployeeRepository _employeeRepository; public EmploymentEducationAppService( IEmploymentEducationRepository employmentEducationRepository, EmploymentEducationManager employmentEducationManager, IEmployeeRepository employeeRepository) { _employmentEducationRepository = employmentEducationRepository; _employmentEducationManager = employmentEducationManager; _employeeRepository = employeeRepository; } public async Task<EmploymentEducationDto> GetAsync(Guid id) { var employment = await _employmentEducationRepository.GetAsync(id); var employmentDto = ObjectMapper.Map<EmploymentEducation, EmploymentEducationDto>(employment); var employee = await _employeeRepository.GetAsync(employment.EmployeeID); employmentDto.EmployeeName = employee.FirstName; return employmentDto; } public async Task<ListResultDto<EmploymentEducationLookupDto>> GetEmployeeLookupAsync() { var employees = await _employeeRepository.GetListAsync(); return new ListResultDto<EmploymentEducationLookupDto>( ObjectMapper.Map<List<Employee>, List<EmploymentEducationLookupDto>>(employees) ); } private async Task<Dictionary<Guid, Employee>> GetEmployeeDictionaryAsync(List<EmploymentEducation> employments) { var employeeIds = employments .Select(b => b.EmployeeID) .Distinct() .ToArray(); var queryable = await _employeeRepository.GetQueryableAsync(); var employees = await AsyncExecuter.ToListAsync( queryable.Where(a => employeeIds.Contains(a.Id)) ); return employees.ToDictionary(x => x.Id, x => x); } public async Task<PagedResultDto<EmploymentEducationDto>> GetListAsync(GetEmploymentEducationListDto input) { var employmentEducation = await _employmentEducationRepository.GetListAsync( input.SkipCount, input.MaxResultCount, input.Sorting, input.Filter ); var totalCount = input.Filter == null ? await _employmentEducationRepository.CountAsync() : await _employmentEducationRepository.CountAsync(); var queryable = await _employmentEducationRepository.GetQueryableAsync(); var employments = await AsyncExecuter.ToListAsync( queryable .OrderBy(input.Sorting) .Skip(input.SkipCount) .Take(input.MaxResultCount) ); var employmentDtos = ObjectMapper.Map<List<EmploymentEducation>, List<EmploymentEducationDto>>(employments); var employeeDictionary = await GetEmployeeDictionaryAsync(employments); employmentDtos.ForEach(employmentDtos => employmentDtos.EmployeeName = employeeDictionary[employmentDtos.EmployeeID].FirstName); return new PagedResultDto<EmploymentEducationDto>( totalCount, employmentDtos ); } [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Create)] public async Task<EmploymentEducationDto> CreateAsync(CreateEmploymentEducationDto input) { var employee = await _employmentEducationManager.CreateAsync( input.EmployeeID, input.Employment, input.Education ); await _employmentEducationRepository.InsertAsync(employee); return ObjectMapper.Map<EmploymentEducation, EmploymentEducationDto>(employee); } [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Edit)] public async Task UpdateAsync(Guid id, UpdateEmploymentEducationDto input) { var employee = await _employmentEducationRepository.GetAsync(id); employee.EmployeeID = input.EmployeeID; employee.Employment = input.Employment; await _employmentEducationRepository.UpdateAsync(employee); } [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Delete)] public async Task DeleteAsync(Guid id) { await _employmentEducationRepository.DeleteAsync(id); } } }
Pls check
-
0
Your issue may be related to mapper. Could you please check?
If the problem is not resolved please share the relevant logs, thank you.
Mapper is ok.
I am attaching the snippet of log where the error is showing:2021-08-03 11:31:13.516 +05:30 [INF] Authorization was successful. 2021-08-03 11:31:13.525 +05:30 [INF] Executing endpoint 'ZW.EmpSvc.EmploymentEducations.EmploymentEducationAppService.CreateAsync (ZW.EmpSvc.Application)' 2021-08-03 11:31:13.542 +05:30 [INF] Route matched with {action = "Create", controller = "EmploymentEducation", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[ZW.EmpSvc.EmploymentEducations.EmploymentEducationDto] CreateAsync(ZW.EmpSvc.EmploymentEducations.CreateEmploymentEducationDto) on controller ZW.EmpSvc.EmploymentEducations.EmploymentEducationAppService (ZW.EmpSvc.Application). 2021-08-03 11:31:13.544 +05:30 [DBG] Login Url: /Account/Login 2021-08-03 11:31:13.544 +05:30 [DBG] Login Return Url Parameter: ReturnUrl 2021-08-03 11:31:13.544 +05:30 [DBG] Logout Url: /Account/Logout 2021-08-03 11:31:13.544 +05:30 [DBG] ConsentUrl Url: /Consent 2021-08-03 11:31:13.544 +05:30 [DBG] Consent Return Url Parameter: returnUrl 2021-08-03 11:31:13.544 +05:30 [DBG] Error Url: /Account/Error 2021-08-03 11:31:13.544 +05:30 [DBG] Error Id Parameter: errorId 2021-08-03 11:31:13.644 +05:30 [ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": { "ActivatorChain": "Castle.Proxies.EmploymentEducationAppServiceProxy" }, "validationErrors": null } 2021-08-03 11:31:13.647 +05:30 [ERR] An exception was thrown while activating Castle.Proxies.EmploymentEducationAppServiceProxy. Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.EmploymentEducationAppServiceProxy. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'Castle.Proxies.EmploymentEducationAppServiceProxy' can be invoked with the available services and parameters: Cannot resolve parameter 'ZW.EmpSvc.EmploymentEducations.IEmploymentEducationRepository employmentEducationRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], ZW.EmpSvc.EmploymentEducations.IEmploymentEducationRepository, ZW.EmpSvc.EmploymentEducations.EmploymentEducationManager, ZW.EmpSvc.Employees.IEmployeeRepository)'. at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters) at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next) --- End of inner exception stack trace --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2021-08-03 11:31:13.659 +05:30 [ERR] ---------- Exception Data ---------- ActivatorChain = Castle.Proxies.EmploymentEducationAppServiceProxy 2021-08-03 11:31:13.682 +05:30 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'. 2021-08-03 11:31:13.698 +05:30 [INF] Executed action ZW.EmpSvc.EmploymentEducations.EmploymentEducationAppService.CreateAsync (ZW.EmpSvc.Application) in 155.3672ms
-
-1
Did you add your Employment, EmploymentEducation and Education classes into your dbcontext class? (Like below)
... public DbSet<Employment> Employments {get; set;} public DbSet<EmploymentEducation> EmploymentEducations {get; set;} public DbSet<Education> Educations {get; set;} ...
-
0
Did you add your Employment, EmploymentEducation and Education classes into your dbcontext class? (Like below)
... public DbSet<Employment> Employments {get; set;} public DbSet<EmploymentEducation> EmploymentEducations {get; set;} public DbSet<Education> Educations {get; set;} ...
We are using mongodb as database. We are using single class with multiple array :
public IMongoCollection<EmploymentEducation> EmploymentEducation => Collection<EmploymentEducation>(); modelBuilder.Entity<EmploymentEducation>(b => { b.CollectionName = "EmploymentEducation"; });
We are creating this class in domain project
public ICollection<Employment> Employment { get; set; } public ICollection<Education> Education { get; set; }
and this is what is in domain.shared
public class Education { public string SchoolName { get; set; } public string Degree_Diploma { get; set; } public string Course { get; set; } public string GradeAchieved { get; set; } public DateTime CourseStartPeriod { get; set; } public DateTime CourseEndPeriod { get; set; } public DateTime DateOfCompletion { get; set; } public string FieldOfStudy { get; set; } } public class Employment { public string PrevCompanyName { get; set; } public string JobTitle { get; set; } public string EmploymentPeriod { get; set; } public string Designation { get; set; } public int TotalSalary { get; set; } public string References { get; set; } }
-
0
Can you share your
EmploymentEducationRepository
class? -
0
-
0
Can you share your
EmploymentEducationRepository
class?Yes,,here it is:
Thanks,
Can you also check your EmploymentEducationRepository class? Is it both inherit from
MongoDbRepository<IMyMongoDbContext, EmploymentEducation, Guid>
andIEmploymentRepository
?It's recommended.
-
0
Can you share your
EmploymentEducationRepository
class?Yes,,here it is:
Thanks,
Can you also check your EmploymentEducationRepository class? Is it both inherit from
MongoDbRepository<IMyMongoDbContext, EmploymentEducation, Guid>
andIEmploymentRepository
?It's recommended.
Yes... it worked when we are inheriting both. But the problem is that there is "precompanyname" which is coming from another class (employment)
How do we use that as this class (Employment) is in Domain.Shared Project? and we are using this class in domain project as a collection.
(How to access the property of a collection class)
Here is the code:
using MongoDB.Driver.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using MongoDB.Driver; using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using ZW.EmpSvc.EmploymentEducations; using ZW.EmpSvc.Employments;
namespace ZW.EmpSvc.MongoDB.EmploymentEducations { public class MongoDbEmploymentEducationRepository : MongoDbRepository<EmpSvcMongoDbContext, EmploymentEducation, Guid> , IEmploymentEducationRepository
{ public MongoDbEmploymentEducationRepository( IMongoDbContextProvider<EmpSvcMongoDbContext> dbContextProvider ) : base(dbContextProvider) { } public async Task<List<EmploymentEducation>> GetListAsync( int skipCount, int maxResultCount, string sorting, string filter = null ) { var queryable = await GetMongoQueryableAsync(); return await queryable .WhereIf<EmploymentEducation, IMongoQueryable<EmploymentEducation>>( !filter.IsNullOrWhiteSpace(), employment => employment.PreCompanyName.Contains(filter) ) .OrderBy(sorting) .As<IMongoQueryable<EmploymentEducation>>() //.Skip(skipCount) //.Take(maxResultCount) .ToListAsync(); } }
}
-
1
Hi again @commitdeveloper1, you can not access directly to precompanyname property because you are keeping Employment as collection instead of class. In other words, you need to iterate to collection to reach its properties.
public async Task<List<EmploymentEducation>> GetListAsync(int skipCount, int maxResultCount, string sorting, string filter = null) { var queryable = await GetMongoQueryableAsync(); return await queryable .WhereIf<EmploymentEducation, IMongoQueryable<EmploymentEducation>>( !filter.IsNullOrWhiteSpace(), //you need to iterate collection to reach its properties(prevcompanyname) employment => employment.Employments.Any(x => x.PrevCompanyName.Contains(filter)) ) .OrderBy(sorting) .As<IMongoQueryable<EmploymentEducation>>() //.Skip(skipCount) //.Take(maxResultCount) .ToListAsync(); }
-
0
Hi again @commitdeveloper1, you can not access directly to precompanyname property because you are keeping Employment as collection instead of class. In other words, you need to iterate to collection to reach its properties.
public async Task<List<EmploymentEducation>> GetListAsync(int skipCount, int maxResultCount, string sorting, string filter = null) { var queryable = await GetMongoQueryableAsync(); return await queryable .WhereIf<EmploymentEducation, IMongoQueryable<EmploymentEducation>>( !filter.IsNullOrWhiteSpace(), //you need to iterate collection to reach its properties(prevcompanyname) employment => employment.Employments.Any(x => x.PrevCompanyName.Contains(filter)) ) .OrderBy(sorting) .As<IMongoQueryable<EmploymentEducation>>() //.Skip(skipCount) //.Take(maxResultCount) .ToListAsync(); }
Thanks... We got it now :)