2
votes

I'm migrating a project from spring boot 1.5.10 to spring boot 2.0.3, I installed the dependency "spring-boot-properties-migrator", it told me that properties change and everything is fine, but now I have this error and I do not know how fix it, I tried everything.

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties;

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties;

Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties;

config.properties
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=test
spring.datasource.password=test
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialization-mode=always
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>hello</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>hello</name>
    <description>hello website</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-properties-migrator</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <!-- hot swapping, disable cache for template, enable live reload -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time-jsptags</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time-hibernate</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.jadira.usertype</groupId>
            <artifactId>usertype.core</artifactId>
            <version>5.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
            <version>2.0.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox-tools</artifactId>
            <version>2.0.9</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.bytedeco.javacpp-presets</groupId>
            <artifactId>tesseract-platform</artifactId>
            <version>3.05.01-1.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mailjet</groupId>
            <artifactId>mailjet-client</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

[INFO] com.example:hello:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-properties-migrator:jar:2.0.3.RELEASE:runtime
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.0.3.RELEASE:compile
[INFO] |  \- org.springframework.boot:spring-boot-configuration-metadata:jar:2.0.3.RELEASE:runtime
[INFO] |     \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.3.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.3.RELEASE:compile
[INFO] |  |  +- com.zaxxer:HikariCP:jar:2.7.9:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:5.0.7.RELEASE:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.2.17.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.2.Final:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.22.0-GA:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] |  |  +- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.0.8.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.0.8.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.0.7.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:5.0.7.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.0.7.RELEASE:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.0.7.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.0.3.RELEASE:compile
[INFO] |  +- org.thymeleaf:thymeleaf-spring5:jar:3.0.9.RELEASE:compile
[INFO] |  |  \- org.thymeleaf:thymeleaf:jar:3.0.9.RELEASE:compile
[INFO] |  |     +- org.attoparser:attoparser:jar:2.0.4.RELEASE:compile
[INFO] |  |     \- org.unbescape:unbescape:jar:1.1.5.RELEASE:compile
[INFO] |  \- org.thymeleaf.extras:thymeleaf-extras-java8time:jar:3.0.1.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.0.7.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:5.0.6.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-core:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:5.0.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.0.7.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.0.3.RELEASE:compile (optional) 
[INFO] |  \- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.3.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.3.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.6:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.3.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.31:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.31:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.10.Final:compile
[INFO] |  |  \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  +- org.springframework:spring-web:jar:5.0.7.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.0.7.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:2.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:5.0.7.RELEASE:compile
[INFO] |  +- org.springframework:spring-context-support:jar:5.0.7.RELEASE:compile
[INFO] |  \- com.sun.mail:javax.mail:jar:1.6.1:compile
[INFO] |     \- javax.activation:activation:jar:1.1:compile
[INFO] +- joda-time:joda-time:jar:2.9.9:compile
[INFO] +- joda-time:joda-time-jsptags:jar:1.1.1:compile
[INFO] +- joda-time:joda-time-hibernate:jar:1.4:compile
[INFO] +- org.jadira.usertype:usertype.core:jar:5.0.0.GA:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:5.2.17.Final:compile
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.7.11:compile
[INFO] |  |  \- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.1.Final:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  \- org.jadira.usertype:usertype.spi:jar:5.0.0.GA:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.46:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.3.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.3.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.3.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.3:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.2:test
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] |  +- junit:junit:jar:4.12:compile
[INFO] |  +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] |  +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  +- org.springframework:spring-core:jar:5.0.7.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.0.7.RELEASE:compile
[INFO] |  +- org.springframework:spring-test:jar:5.0.7.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:3.0.2.RELEASE:compile
[INFO] +- org.apache.pdfbox:pdfbox:jar:2.0.9:compile
[INFO] |  +- org.apache.pdfbox:fontbox:jar:2.0.9:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.apache.pdfbox:pdfbox-tools:jar:2.0.9:compile
[INFO] |  \- org.apache.pdfbox:pdfbox-debugger:jar:2.0.9:compile
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- org.bytedeco.javacpp-presets:tesseract-platform:jar:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:leptonica-platform:jar:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:android-arm:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:android-arm64:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:android-x86:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:android-x86_64:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:linux-x86:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:linux-x86_64:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:linux-armhf:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:linux-ppc64le:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:macosx-x86_64:1.75.3-1.4.1:compile
[INFO] |  |  +- org.bytedeco.javacpp-presets:leptonica:jar:windows-x86:1.75.3-1.4.1:compile
[INFO] |  |  \- org.bytedeco.javacpp-presets:leptonica:jar:windows-x86_64:1.75.3-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:3.05.01-1.4.1:compile
[INFO] |  |  \- org.bytedeco:javacpp:jar:1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:android-arm:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:android-arm64:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:android-x86:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:android-x86_64:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:linux-x86:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:linux-x86_64:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:linux-armhf:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:linux-ppc64le:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:macosx-x86_64:3.05.01-1.4.1:compile
[INFO] |  +- org.bytedeco.javacpp-presets:tesseract:jar:windows-x86:3.05.01-1.4.1:compile
[INFO] |  \- org.bytedeco.javacpp-presets:tesseract:jar:windows-x86_64:3.05.01-1.4.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.0.3.RELEASE:compile
[INFO] |  \- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] +- com.mailjet:mailjet-client:jar:4.1.1:compile
[INFO] |  +- com.turbomanage.basic-http-client:http-client-java:jar:0.89:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
[INFO] |  \- org.json:json:jar:20140107:compile
[INFO] +- org.springframework.boot:spring-boot-starter-amqp:jar:2.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-messaging:jar:5.0.7.RELEASE:compile
[INFO] |  \- org.springframework.amqp:spring-rabbit:jar:2.0.4.RELEASE:compile
[INFO] |     +- org.springframework.amqp:spring-amqp:jar:2.0.4.RELEASE:compile
[INFO] |     +- com.rabbitmq:amqp-client:jar:5.1.2:compile
[INFO] |     \- org.springframework.retry:spring-retry:jar:1.2.2.RELEASE:compile
[INFO] \- com.google.code.gson:gson:jar:2.8.5:compile
1
Show your pom.xml or build.gradle. The error indicates, that you have a version mismatch in your dependencies, most likely because you have overridden the version for Hibernate, and you didn't upgrade that as well, when you upgraded Spring Boot.dunni
I added my pom.xml to the questionYunier Broche Guevara
Can you run mvn dependency:tree and post the output as well? Or if you know how to read the output, check if the Hibernate version, which is defined by Spring Boot, is overridden to an older version e.g. by joda-time-hibernate or by usertype.coredunni
I added my output for "mvn dependency:tree"Yunier Broche Guevara
PDFBox is now at 2.0.10. (unrelated to your question)Tilman Hausherr

1 Answers

0
votes

I am using Jadira 5.0 which, AFAIK, only supports Hibernate 5.0. Boot 2.0 requires Hibernate 5.2.