Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Trying to run in docker - Value cannot be null #6785


User avatar
0
terry21 created

I am trying to run my AspNet Zero application (Abp v4.3 & netcoreapp2.2) from a docker container. I am able to successfully bring up the http://localhost:9901/swagger web page. Unfortunately if I try to execute the IsTenantAvailable API (or anything else) I get a 500 error code I cannot interpret much from the the log file (see below). I get a similar error when I try to run the angular client (localhost:9902)  and it executes the AbpUserConfigurationController.GetAll I think this may be related to the service in the container not being able to access the SQL Server that is on the host as I don't see anything in SQL Profiler coming from the container. For the connection string, I have tried using the static IP address of the host (with port) and also tried with the "host.docker.internal,1433"

Any help on what may be wrong or how I can collect more information on the error would be appreciated. Thanks

INFO 2019-04-04 14:02:49,718 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:9901/swagger/index.html INFO 2019-04-04 14:02:50,374 [5 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:9901/swagger/ui/abp.swagger.js INFO 2019-04-04 14:02:50,376 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 651.3126ms 200 text/html INFO 2019-04-04 14:02:50,379 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:9901/swagger/ui/abp.js INFO 2019-04-04 14:02:50,404 [4 ] NetCore.StaticFiles.StaticFileMiddleware - The file /swagger/ui/abp.js was not modified INFO 2019-04-04 14:02:50,404 [5 ] NetCore.StaticFiles.StaticFileMiddleware - The file /swagger/ui/abp.swagger.js was not modified INFO 2019-04-04 14:02:50,413 [5 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 38.6491ms 304 application/javascript INFO 2019-04-04 14:02:50,413 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 33.9876ms 304 application/javascript INFO 2019-04-04 14:02:52,450 [5 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:9901/swagger/v1/swagger.json INFO 2019-04-04 14:02:52,989 [5 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 539.2978ms 200 application/json;charset=utf-8 INFO 2019-04-04 14:03:14,977 [4 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 POST http://localhost:9901/api/services/app/Account/IsTenantAvailable application/json-patch+json 30 INFO 2019-04-04 14:03:14,986 [4 ] pNetCore.Cors.Infrastructure.CorsService - CORS policy execution successful. INFO 2019-04-04 14:03:15,005 [4 ] ft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint 'AspenTechnology.AspenPortal.Authorization.Accounts.AccountAppService.IsTenantAvailable (AspenTechnology.AspenPortal.Application)' INFO 2019-04-04 14:03:15,164 [4 ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {area = "app", action = "IsTenantAvailable", controller = "Account"}. Executing action AspenTechnology.AspenPortal.Authorization.Accounts.AccountAppService.IsTenantAvailable (AspenTechnology.AspenPortal.Application) INFO 2019-04-04 14:03:15,180 [4 ] pNetCore.Cors.Infrastructure.CorsService - CORS policy execution successful. ERROR 2019-04-04 14:03:16,177 [4 ] Mvc.ExceptionHandling.AbpExceptionFilter - Value cannot be null. Parameter name: key System.ArgumentNullException: Value cannot be null. Parameter name: key at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value) at Abp.Collections.Extensions.DictionaryExtensions.GetOrDefault[TKey,TValue](IDictionary2 dictionary, TKey key) at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.CreateDbContext[TDbContext](String connectionString, IDbContextResolver dbContextResolver) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext](Nullable1 multiTenancySide, String name) at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.get_Table() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.GetAllIncluding(Expression1[] propertySelectors) at Abp.Domain.Repositories.AbpRepositoryBase2.FirstOrDefault(TPrimaryKey id) at Castle.Proxies.Invocations.IRepository2_FirstOrDefault.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.IRepository1Proxy.FirstOrDefault(Int32 id) at Abp.MultiTenancy.TenantCache2.GetTenantOrNull(Int32 tenantId) at Castle.Proxies.Invocations.TenantCache2_GetTenantOrNull.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.TenantCache2Proxy.GetTenantOrNull(Int32 tenantId) at Abp.MultiTenancy.TenantCache2.<&gt;c__DisplayClass7_0.b__0()

at Abp.Runtime.Caching.CacheExtensions.<&gt;c__DisplayClass5_02.<Get>b__0(String k) at Abp.Runtime.Caching.CacheBase.Get(String key, Func2 factory) at Abp.Runtime.Caching.CacheExtensions.Get[TKey,TValue](ICache cache, TKey key, Func2 factory) at Castle.Proxies.Invocations.ITenantCache_GetOrNull.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.TenantCache2Proxy.GetOrNull(Int32 tenantId) at Abp.MultiTenancy.TenantStore.Find(Int32 tenantId) at Abp.MultiTenancy.TenantResolver.GetTenantIdFromContributors() at Abp.MultiTenancy.TenantResolver.ResolveTenantId() at Abp.Runtime.Session.ClaimsAbpSession.get_TenantId() at Abp.Auditing.AuditingHelper.CreateAuditInfo(Type type, MethodInfo method, IDictionary`2 arguments) at Abp.AspNetCore.Mvc.Auditing.AbpAuditActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync() INFO 2019-04-04 14:03:16,257 [4 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2019-04-04 14:03:16,287 [4 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action AspenTechnology.AspenPortal.Authorization.Accounts.AccountAppService.IsTenantAvailable (AspenTechnology.AspenPortal.Application) in 1117.1855ms INFO 2019-04-04 14:03:16,287 [4 ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'AspenTechnology.AspenPortal.Authorization.Accounts.AccountAppService.IsTenantAvailable (AspenTechnology.AspenPortal.Application)'


4 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Your connection string is null.

  • User Avatar
    0
    terry21 created

    Thanks aaron.

    Do you have any idea why the connection string would be null? I have put the static IP address in the Connection string in appsettings.json and can run it on the work station. I checked appsettings.Staging.json in the build\outputs\Host folder and it has the same connection string. (The docker ASPNETCORE_ENVIRONMENT=Staging") Also, do you know what the entries should be for ServerRootAddress and ClientRootAddress for docker?

    Thanks

  • User Avatar
    0
    aaron created
    Support Team

    Can you try running with ASPNETCORE_ENVIRONMENT=Staging on your work station?

    Also, do you know what the entries should be for ServerRootAddress and ClientRootAddress for docker?

    Should be same as non-Docker.

  • User Avatar
    0
    terry21 created

    Thanks aaron for your help! The source of the problem was a snippet of code I had added while trying to create separate DbContexts for each of the plugin applications. This code was no longer needed but must have been interfering with the connection string when running in docker.