Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

stackResourceRegistryFactoryBean returns null value #496

@reypader

Description

@reypader

Encountering a problem with starting an application using spring-cloud-starter-aws:2.1.0.RELEASE with cloud.aws.stack.auto = false. The application encounters the following error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stackResourceRegistryFactoryBean' defined in class path resource [org/springframework/cloud/aws/autoconfigure/context/ContextStackAutoConfiguration.class]: Initialization of bean failed; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.support.NullBean cannot be cast to org.springframework.beans.factory.FactoryBean

This is likely due to org.springframework.cloud.aws.autoconfigure.context.ContextStackAutoConfiguration.stackResourceRegistryFactoryBean() returning null.

@Bean
    @ConditionalOnMissingBean(StackResourceRegistry.class)
    public StackResourceRegistryFactoryBean stackResourceRegistryFactoryBean(AmazonCloudFormation amazonCloudFormation) {

        if (StringUtils.hasText(environment.getProperty("cloud.aws.stack.name"))) {
            return new StackResourceRegistryFactoryBean(amazonCloudFormation, new StaticStackNameProvider(this.environment.getProperty("cloud.aws.stack.name")));
        }

        if (environment.getProperty("cloud.aws.stack.auto") == null || "true".equalsIgnoreCase(environment.getProperty("cloud.aws.stack.auto"))) {
            return new StackResourceRegistryFactoryBean(amazonCloudFormation, new AutoDetectingStackNameProvider(amazonCloudFormation, this.amazonEC2));
        }

        return null;
    }

Should this be changed to use @ConditionalOnProperty("cloud.aws.stack.name") and @ConditionalOnProperty("cloud.aws.stack.auto") ?

Metadata

Metadata

Labels

component: coreAn issue related to core functionality - credentials, region resolutionstatus: in-progressAn issue that being worked ontype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions