Open Closed

add CmsKit module as service to microservice template (studio version) #6693


User avatar
0
hitaspdotnet created
  • ABP Framework version: v8.0.2
  • UI Type: Microservice - MVC - Created using ABP Studio
  • Database System: MongoDB
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: N/A
  • Steps to reproduce the issue:
  1. Add new service using Studio UI - template: service-nolayer
  2. Apply step-by-step the required changes which are well described in the services/cms/README.md file
  3. Add cmskit-pro modules using Studio's import module
    • Add Volo.CmsKit.Pro.Application.Contracts to the MyProject.CmsService.Contracts
    • Add Volo.CmsKit.Pro.Application, Volo.CmsKit.Pro.HttpApi and Volo.CmsKit.Pro.MongoDB to the MyProject.CmsService
    • Add Volo.CmsKit.Pro.Domain.Shared to the MyProject.AdministrationService for permissions and features
    • Add Volo.CmsKit.Pro.Web, Volo.CmsKit.Pro.HttpApi.Client and MyProject.CmsService.Contracts to the MyProject.Web
  4. Enable CmsKit and CmsKitPro global features for
    • MyProject.CmsService.Contracts
    • MyProject.AdministrationService
    • MyProject.Web
  5. Replace ICmsKitProMongoDbContext and ICmsKitMongoDbContext via CmsServiceDbContext using ReplaceDbContext attribute.
  6. Run the application.

CMS Features:

Permissions

What did I forget?


5 Answer(s)
  • User Avatar
    0
    hitaspdotnet created

    Add Volo.CmsKit.Pro.Domain.Shared to the MyProject.AdministrationService for permissions and features

    I added Volo.CmsKit.Pro.Application.Contracts and now the permissions are available too. But, I have System.ArgumentNullException for connectionString in CmsService and its throw at Blog Posts index.

    any other pages work as expected.

       at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName)
       at MongoDB.Driver.Core.Configuration.ConnectionString..ctor(String connectionString, Boolean isInternalRepresentation, IDnsResolver dnsResolver)
       at MongoDB.Driver.Core.Configuration.ConnectionString..ctor(String connectionString)
       at MongoDB.Driver.MongoUrlBuilder.Parse(String url)
       at MongoDB.Driver.MongoUrlBuilder..ctor(String url)
       at MongoDB.Driver.MongoUrl..ctor(String url)
       at Volo.Abp.Uow.MongoDB.UnitOfWorkMongoDbContextProvider`1.GetDbContextAsync(CancellationToken cancellationToken)
       at Volo.CmsKit.MongoDB.Blogs.MongoBlogPostRepository.GetListAsync(String filter, Nullable`1 blogId, Nullable`1 authorId, Nullable`1 tagId, Nullable`1 statusFilter, Int32 maxResultCount, Int32 skipCount, String sorting, CancellationToken cancellationToken)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at Volo.CmsKit.Admin.Blogs.BlogPostAdminAppService.GetListAsync(BlogPostGetListInput input)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope)
       at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.Features.FeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
       at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
       at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
       at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
       at lambda_method1790(Closure, Object)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeInnerFilterAsync&gt;g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
    

    I think this is related to CmsUser and userLookup service. But I already configured connectionStringMap for abpIdentity:

    Configure&lt;AbpDbConnectionOptions&gt;(options =>
    {
        options.Databases.Configure("Administration", database =>
        {
            database.MappedConnections.Add(AbpPermissionManagementDbProperties.ConnectionStringName);
            database.MappedConnections.Add(AbpFeatureManagementDbProperties.ConnectionStringName);
            database.MappedConnections.Add(AbpSettingManagementDbProperties.ConnectionStringName);
            database.MappedConnections.Add(LanguageManagementDbProperties.ConnectionStringName);
        });
        options.Databases.Configure("Identity", database =>
        {
            database.MappedConnections.Add(AbpIdentityDbProperties.ConnectionStringName);
        });
        
        options.Databases.Configure("AuditLoggingService", database =>
        {
            database.MappedConnections.Add(AbpAuditLoggingDbProperties.ConnectionStringName);
        });
        
        options.Databases.Configure("SaasService", database =>
        {
            database.MappedConnections.Add(SaasDbProperties.ConnectionStringName);
        });
    });
    
  • User Avatar
    0
    hitaspdotnet created

    It was solved after mapping AbpCmsKitDbProperties.ConnectionStringName to service connectionString

  • User Avatar
    0
    hitaspdotnet created

    Everything works as expected in admin and public side, but the creation of the blog post does not. I have DI exception:

    DependencyResolutionException: None of the constructors found on type 'Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags.Components.TagEditor.TagEditorViewComponent' can be invoked with the available services and parameters:
    Cannot resolve parameter 'Volo.CmsKit.Tags.ITagAppService tagAppService' of constructor 'Void .ctor(Volo.CmsKit.Tags.ITagAppService)'.
    
    See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
    Autofac.Core.Activators.Reflection.ReflectionActivator+<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action<ResolveRequestContext> next)
    
    DependencyResolutionException: An exception was thrown while activating Volo.CmsKit.Admin.Web.Pages.CmsKit.Tags.Components.TagEditor.TagEditorViewComponent.
    Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action<ResolveRequestContext> next)
    
  • User Avatar
    0
    hitaspdotnet created

    OK. I found the error. TagAppService is only implemented in public package but used in admin package.

    as workaround, We also need to add the CmsKitProPublicHttpApiClientModule to the web but I am waiting for a response, maybe a better way will be suggested from the team.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    It's basically correct, You are doing the right things.

    Your questions credit has been refunded.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09