jhipster / generator-jhipster-micronaut

Micronaut blueprint for JHipster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot execute a brand new application, Error instantiating bean of type [io.micronaut.security.oauth2.routes.OauthRouteBuilder]

devops-myefm opened this issue · comments

I've created a microservice application from scratch just to give a try, ran a jhipster registry instance using the docker-compose file generated and than executed ./gradlew to see the result.

Unfortunately it gave me this exception during boot:

13:50:16.476 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Bean definition [com.mycompany.myapp.config.LoggingConfiguration] could not be loaded: Error instantiating bean of type [io.micronaut.security.oauth2.routes.OauthRouteBuilder]

Path Taken: new RxNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration,HttpClientFilterResolver httpClientFilterResolver,[LoadBalancerResolver loadBalancerResolver],NettyClientSslBuilder nettyClientSslBuilder,ThreadFactory threadFactory,MediaTypeCodecRegistry codecRegistry,EventLoopGroupRegistry eventLoopGroupRegistry,EventLoopGroupFactory eventLoopGroupFactory,BeanContext beanContext) --> new DefaultLoadBalancerResolver(BeanContext beanContext,[List serviceInstanceLists]) --> new EurekaServiceInstanceList([EurekaConfiguration configuration],InstanceConfiguration instanceConfiguration) --> new EurekaConfiguration(EurekaConnectionPoolConfiguration eurekaConnectionPoolConfiguration,ApplicationConfiguration applicationConfiguration,[EurekaRegistrationConfiguration eurekaRegistrationConfiguration]) --> new EurekaRegistrationConfiguration([EmbeddedServer embeddedServer],ApplicationConfiguration applicationConfiguration,DataCenterInfo dataCenterInfo,String appName,String hostname,Integer port,String ipAddr,String instanceId,Boolean preferIpAddress) --> new NettyHttpServer(NettyHttpServerConfiguration serverConfiguration,ApplicationContext applicationContext,[Router router],RequestArgumentSatisfier requestArgumentSatisfier,MediaTypeCodecRegistry mediaTypeCodecRegistry,NettyCustomizableResponseTypeHandlerRegistry customizableResponseTypeHandlerRegistry,StaticResourceResolver resourceResolver,Provider ioExecutor,ThreadFactory threadFactory,ExecutorSelector executorSelector,ServerSslBuilder serverSslBuilder,List outboundHandlers,EventLoopGroupFactory eventLoopGroupFactory,EventLoopGroupRegistry eventLoopGroupRegistry,HttpCompressionStrategy httpCompressionStrategy,HttpContentProcessorResolver httpContentProcessorResolver,ChannelOptionFactory channelOptionFactory) --> new DefaultRouter([Collection builders]) --> new OauthRouteBuilder(ExecutionHandleLocator executionHandleLocator,UriNamingStrategy uriNamingStrategy,ConversionService conversionService,BeanContext beanContext,OauthConfiguration oauthConfiguration,OauthRouteUrlBuilder oauthRouteUrlBuilder,[List controllerList]) io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [com.mycompany.myapp.config.LoggingConfiguration] could not be loaded: Error instantiating bean of type [io.micronaut.security.oauth2.routes.OauthRouteBuilder]

Path Taken: new RxNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration,HttpClientFilterResolver httpClientFilterResolver,[LoadBalancerResolver loadBalancerResolver],NettyClientSslBuilder nettyClientSslBuilder,ThreadFactory threadFactory,MediaTypeCodecRegistry codecRegistry,EventLoopGroupRegistry eventLoopGroupRegistry,EventLoopGroupFactory eventLoopGroupFactory,BeanContext beanContext) --> new DefaultLoadBalancerResolver(BeanContext beanContext,[List serviceInstanceLists]) --> new EurekaServiceInstanceList([EurekaConfiguration configuration],InstanceConfiguration instanceConfiguration) --> new EurekaConfiguration(EurekaConnectionPoolConfiguration eurekaConnectionPoolConfiguration,ApplicationConfiguration applicationConfiguration,[EurekaRegistrationConfiguration eurekaRegistrationConfiguration]) --> new EurekaRegistrationConfiguration([EmbeddedServer embeddedServer],ApplicationConfiguration applicationConfiguration,DataCenterInfo dataCenterInfo,String appName,String hostname,Integer port,String ipAddr,String instanceId,Boolean preferIpAddress) --> new NettyHttpServer(NettyHttpServerConfiguration serverConfiguration,ApplicationContext applicationContext,[Router router],RequestArgumentSatisfier requestArgumentSatisfier,MediaTypeCodecRegistry mediaTypeCodecRegistry,NettyCustomizableResponseTypeHandlerRegistry customizableResponseTypeHandlerRegistry,StaticResourceResolver resourceResolver,Provider ioExecutor,ThreadFactory threadFactory,ExecutorSelector executorSelector,ServerSslBuilder serverSslBuilder,List outboundHandlers,EventLoopGroupFactory eventLoopGroupFactory,EventLoopGroupRegistry eventLoopGroupRegistry,HttpCompressionStrategy httpCompressionStrategy,HttpContentProcessorResolver httpContentProcessorResolver,ChannelOptionFactory channelOptionFactory) --> new DefaultRouter([Collection builders]) --> new OauthRouteBuilder(ExecutionHandleLocator executionHandleLocator,UriNamingStrategy uriNamingStrategy,ConversionService conversionService,BeanContext beanContext,OauthConfiguration oauthConfiguration,OauthRouteUrlBuilder oauthRouteUrlBuilder,[List controllerList]) at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1549) at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:220) at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:2780) at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:233) at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:166) at io.micronaut.runtime.Micronaut.start(Micronaut.java:64) at com.mycompany.myapp.DefaultmicronautApp.main(DefaultmicronautApp.java:69) Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [io.micronaut.security.oauth2.routes.OauthRouteBuilder]

Path Taken: new RxNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration,HttpClientFilterResolver httpClientFilterResolver,[LoadBalancerResolver loadBalancerResolver],NettyClientSslBuilder nettyClientSslBuilder,ThreadFactory threadFactory,MediaTypeCodecRegistry codecRegistry,EventLoopGroupRegistry eventLoopGroupRegistry,EventLoopGroupFactory eventLoopGroupFactory,BeanContext beanContext) --> new DefaultLoadBalancerResolver(BeanContext beanContext,[List serviceInstanceLists]) --> new EurekaServiceInstanceList([EurekaConfiguration configuration],InstanceConfiguration instanceConfiguration) --> new EurekaConfiguration(EurekaConnectionPoolConfiguration eurekaConnectionPoolConfiguration,ApplicationConfiguration applicationConfiguration,[EurekaRegistrationConfiguration eurekaRegistrationConfiguration]) --> new EurekaRegistrationConfiguration([EmbeddedServer embeddedServer],ApplicationConfiguration applicationConfiguration,DataCenterInfo dataCenterInfo,String appName,String hostname,Integer port,String ipAddr,String instanceId,Boolean preferIpAddress) --> new NettyHttpServer(NettyHttpServerConfiguration serverConfiguration,ApplicationContext applicationContext,[Router router],RequestArgumentSatisfier requestArgumentSatisfier,MediaTypeCodecRegistry mediaTypeCodecRegistry,NettyCustomizableResponseTypeHandlerRegistry customizableResponseTypeHandlerRegistry,StaticResourceResolver resourceResolver,Provider ioExecutor,ThreadFactory threadFactory,ExecutorSelector executorSelector,ServerSslBuilder serverSslBuilder,List outboundHandlers,EventLoopGroupFactory eventLoopGroupFactory,EventLoopGroupRegistry eventLoopGroupRegistry,HttpCompressionStrategy httpCompressionStrategy,HttpContentProcessorResolver httpContentProcessorResolver,ChannelOptionFactory channelOptionFactory) --> new DefaultRouter([Collection builders]) --> new OauthRouteBuilder(ExecutionHandleLocator executionHandleLocator,UriNamingStrategy uriNamingStrategy,ConversionService conversionService,BeanContext beanContext,OauthConfiguration oauthConfiguration,OauthRouteUrlBuilder oauthRouteUrlBuilder,[List controllerList]) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1925) at io.micronaut.context.DefaultBeanContext.addCandidateToList(DefaultBeanContext.java:2990) at io.micronaut.context.DefaultBeanContext.getBeansOfTypeInternal(DefaultBeanContext.java:2891) at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:1045) at io.micronaut.context.AbstractBeanDefinition.lambda$getBeansOfTypeForConstructorArgument$9(AbstractBeanDefinition.java:1143) at io.micronaut.context.AbstractBeanDefinition.resolveBeanWithGenericsFromConstructorArgument(AbstractBeanDefinition.java:1820) at io.micronaut.context.AbstractBeanDefinition.getBeansOfTypeForConstructorArgument(AbstractBeanDefinition.java:1138) at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:990)

Reproduce the error
  • Create a brand new app with default parameters (see configuration below)
  • Run an instance of jhipster registry using docker-compose -f src/main/docker/jhipster-registry.yml up after set the OAuth2 issuer, client-id and client-secret
  • Put the same parameter in src/main/resources/application.yml
  • Run ./gradlew
Related issues

Not found related issues

Project configuration
/home/vcupelloni/defaultmicronaut
└─┬ generator-jhipster-micronaut@0.7.0
  └── generator-jhipster@6.10.5 

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp"
    },
    "jhipsterVersion": "6.10.5",
    "applicationType": "microservice",
    "baseName": "defaultmicronaut",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8081",
    "authenticationType": "oauth2",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "gradle",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "embeddableLaunchScript": false,
    "creationTimestamp": 1611232810219,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-micronaut",
        "version": "0.7.0"
      }
    ],
    "enableTranslation": false,
    "clientPackageManager": "npm",
    "blueprints": [
      {
        "name": "generator-jhipster-micronaut",
        "version": "0.7.0"
      }
    ],
    "skipClient": true,
    "skipUserManagement": true
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+8)
OpenJDK 64-Bit Server VM (build 11.0.10+8, mixed mode)

git version 2.30.0

node: v10.23.1

npm: 6.14.11

yeoman: 3.1.1

yarn: 1.22.10

Docker version 20.10.2, build 2291f610ae

docker-compose version 1.28.0, build unknown

INFO! Congratulations, JHipster execution is complete!

Browsers and Operating System

Chromium on Arch Linux

  • [ X ] Checking this box is mandatory (this is just to show you read everything)

Same issue with 0.8.0
Does anyone know a workaround for this?

I was able to reproduce this, but the bean that fails to instantiate seems to change on each run so I think the specific error above is a red herring. I have seen the OauthRouteBuilder as reported above, but I've also seen other beans including DefaultRouter. I don't know much about the JHipster Registry, but I believe it is running Eureka. I'm suspicious of the Eureka configuration, but that is just a hunch. Some more research is required.

I tried rolling back to version 0.6.0 of the blueprint which is the first that included the microservice application type, and I experienced the same errors there.

@murdos when you did the microservice implementation, did that include Eureka and Conusl? Were you able to configure an app to connect to the JHipster Registry? Any insight you could provide on this issue would be appreciated

After some more digging, it seems that this configuration is resulting in a stackoverflow during bean instantiation. I need to continue to dig a bit more, but that explains why it happens at different points in the process in subsequent runs

Did you check the eureka configuration? At least at first glance it looks totally different from the official micronaut guides, but I don't see why a wrong configuration results in a stackoverflow

Did you check the eureka configuration? At least at first glance it looks totally different from the official micronaut guides, but I don't see why a wrong configuration results in a stackoverflow

I'll take a look at that for the purposes of moving us forward, but I do want to understand the source of the stackoverflow as it may be a bug in mn

It seems that the problematic combination is OpenID and Eureka. If you set micronaut.security.oauth2.enabled to false, or remove the micronaut.security.oauth2.clients.oidc.openid config, the service will start up correctly. I'm going to recreate this with a vanilla Micronaut app and open an issue there.

So we could document this a known issues/limitation for the 1.0 release, what do you think?

So we could document this a known issues/limitation for the 1.0 release, what do you think?

I'm OK with that.

This should be resolved with Micronaut 2.4.3 which we expect to be released within the next few days

Unfortunately, I discovered a different but similar issue after the first issue was resolved. See: micronaut-projects/micronaut-security#634