question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spring 2.1.2 bean creation exception

See original GitHub issue

Expected Behavior

Setup dynamo db

Actual Behavior

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamoDB-DynamoDBMapper': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory.<init>()
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1270)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1164)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:974)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:848)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:574)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:514)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:477)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:471)
	at org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration$DevToolsDataSourceCondition.getMatchOutcome(DevToolsDataSourceAutoConfiguration.java:164)
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
	... 42 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory.<init>()
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:83)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1262)
	... 51 more
Caused by: java.lang.NoSuchMethodException: org.socialsignin.spring.data.dynamodb.repository.config.DynamoDBMapperFactory.<init>()
	at java.base/java.lang.Class.getConstructor0(Class.java:3350)
	at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2554)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78)
	... 52 more

Steps to Reproduce the Problem

  1. Start spring Boot app or run It test

Specifications

  • Spring Data DynamoDB Version: 5.1.0
  • Spring Data Version: 2.1.0
  • AWS SDK Version: 1.11.490
  • Java Version: 11
  • Platform Details: Spring Boot 2.1.2 RELEASE

All those information are logged by org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory on INFO level on startup. Or use java -version and mvn dependency:tree | grep -E 'spring|aws' to provide those version numbers.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:27

github_iconTop GitHub Comments

2reactions
boostchickencommented, Mar 11, 2019

I have Spring Boot 2.1.3 running on 5.1.0 just fine here is come of the config make sure you using the BOM for Spring Data and not hardcoding dependencies versions, Note that this will move you to the Spring Data 2.1.x release train (Lovelace)

ext {
    springDataVersion = 'Lovelace-SR5'
}
buildscript {
    repositories {
        mavenCentral()
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.3.RELEASE")
        classpath "io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE"
    }
}

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

dependencyManagement {
    imports {
        mavenBom "org.springframework.data:spring-data-releasetrain:${springDataVersion}"
    }
}

dependencies {
    implementation  "org.springframework.boot:spring-boot-starter-web"
    implementation  group: 'com.github.derjust', name: 'spring-data-dynamodb', version: '5.1.0'
    implementation  'com.amazonaws:aws-java-sdk-dynamodb:1.11.497'
}

Work’s great here

1reaction
dharbuzovcommented, Apr 3, 2019

By reason of project requirements I can’t change version of Spring Boot and also should support ddl auto for all entities (only version 5.1.0 supports this feature ). I’ve fixed this problem by the following workaround , enabling override the spring beans(be careful with it!!!) you should define @Primary beans:

spring.main.allow-bean-definition-overriding=true

Then in my DynamoDBConfiguration class override DynamoDBMapperFactory bean with allowed constructor and set as primary bean for name ‘dynamoDB-DynamoDBMapper’:

    @Primary
    @Bean(name = "dynamoDB-DynamoDBMapper")
    public DynamoDBMapperFactory dynamoDBMapperFactory() {
        return new DynamoDBMapperFactory(amazonDynamoDB(), dynamoDBMapperConfig());
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring boot 2.1.1 to 2.1.2: Error creating bean with name ...
I use spring-ws-core (3.0.6) on a web-service subproject that is contained in the app. I am using java 11, importing the jaxb dependencies...
Read more >
Spring BeanCreationException - Baeldung
Another similar cause for the bean creation exception is Spring trying to inject a bean by type, namely by its interface, and finding...
Read more >
“How-to” Guides - Spring
FailureAnalyzer is a great way to intercept an exception on startup and turn it into a human-readable message, wrapped in a FailureAnalysis ....
Read more >
Spring Boot - BeanCreationException:Error creating bean with ...
[Solved]-Spring Boot - BeanCreationException:Error creating bean with name 'uploadController'-Springboot ... How about changing your code to this? @Value("${ ...
Read more >
Spring Boot, Maven and Eclipse Errors and TroubleShooting ...
MultipleBagFetchException; Error : BeanCreationException - java.lang.IllegalArgumentException: At least one JPA metamodel must be present ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found