SteeltoeOSS / Samples

Steeltoe samples and reference application collection
https://steeltoe.io/
Apache License 2.0
645 stars 252 forks source link

Connector:PostgreSql sample app fails to start on Cloud Foundry #148

Closed ccheetham closed 4 years ago

ccheetham commented 4 years ago

branch 2.x

When pushing PostgreSql sample app to Cloud Foundry, app fails to start.

Stacktrace from app log:

   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR Unhandled exception. System.AggregateException: One or more errors occurred. (Cannot resolve scoped service 'Npgsql.NpgsqlConnection' from root provider.)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR  ---> System.InvalidOperationException: Cannot resolve scoped service 'Npgsql.NpgsqlConnection' from root provider.
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceProvider.Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceProviderEngineCallback.OnResolve(Type serviceType, IServiceScope scope)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at PostgreSql.Models.SampleData.InitializePostgresData(IServiceProvider serviceProvider) in /Users/ccheetham/src/SteeltoeOSS/Samples/Connectors/src/AspDotNetCore/PostgreSql/Model/SampleData.cs:line 17
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    --- End of inner exception stack trace ---
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at System.Threading.Tasks.Task.Wait()
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at PostgreSql.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in /Users/ccheetham/src/SteeltoeOSS/Samples/Connectors/src/AspDotNetCore/PostgreSql/Startup.cs:line 59
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Steeltoe.Management.CloudFoundry.CloudFoundryActuatorsStartupFilter.<>c__DisplayClass7_0.<Configure>b__0(IApplicationBuilder app)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   2020-04-28T16:46:12.56-0400 [APP/PROC/WEB/0] ERR    at PostgreSql.Program.Main(String[] args) in /Users/ccheetham/src/SteeltoeOSS/Samples/Connectors/src/AspDotNetCore/PostgreSql/Program.cs:line 12
TimHess commented 4 years ago

fixed in https://github.com/SteeltoeOSS/Samples/commit/932450cd10a84cbe67275a0b8b81eb7ea2f35bce