4

I am trying to migrate few services from one spring boot project to another, there were ofcourse many issues but all were resolved except am stuck at this

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector and org.springframework.beans.factory.config.ConfigurableListableBeanFactory

This is my 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
<!--    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.5</version>
        <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;
    </parent>-->
    <groupId>com.hpw</groupId>
    <artifactId>box</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>box</name>
    <description>Box</description>
    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.6.4</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.6.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.3.13</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.6.4</version>
        </dependency>


        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.13.2</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.13.2.2</version>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.9.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>5.6.2</version>
        </dependency>


        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>1.7.36</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <profile>
            <id>local</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>local</build.profile.id>
                <unit-tests.skip>true</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>dev</build.profile.id>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

        <profile>
            <id>qa</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>qa</build.profile.id>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

        <profile>
            <id>stg</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>stg</build.profile.id>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

        <profile>
            <id>prod</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>prod</build.profile.id>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

        <profile>
            <id>singletier</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>singletier</build.profile.id>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

        <profile>
            <id>threetier</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <build.profile.id>threetier</build.profile.id>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>

    </profiles>
</project>

This is the error at console:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector.detect(AnnotationDependsOnDatabaseInitializationDetector.java:36)

The following method did not exist:

    'java.lang.annotation.Annotation org.springframework.beans.factory.config.ConfigurableListableBeanFactory.findAnnotationOnBean(java.lang.String, java.lang.Class, boolean)'

The calling method's class, org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector, was loaded from the following location:

    jar:file:/home/kmj/.m2/repository/org/springframework/boot/spring-boot/2.6.4/spring-boot-2.6.4.jar!/org/springframework/boot/sql/init/dependency/AnnotationDependsOnDatabaseInitializationDetector.class

The called method's class, org.springframework.beans.factory.config.ConfigurableListableBeanFactory, is available from the following locations:

    jar:file:/home/kmj/.m2/repository/org/springframework/spring-beans/5.3.13/spring-beans-5.3.13.jar!/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.class

The called method's class hierarchy was loaded from the following locations:

    org.springframework.beans.factory.config.ConfigurableListableBeanFactory: file:/home/kmj/.m2/repository/org/springframework/spring-beans/5.3.13/spring-beans-5.3.13.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector and org.springframework.beans.factory.config.ConfigurableListableBeanFactory

Disconnected from the target VM, address: '127.0.0.1:46807', transport: 'socket'

Process finished with exit code 1

Can someone help because i tried many things with reconfiguring maven but nothing worked, i have yet so much to learn on project configurations

spencergibb
  • 24,471
  • 6
  • 69
  • 75
kmj
  • 41
  • 2
  • 7

1 Answers1

5

You are loading both 2.6.4 and 2.6.5 versions of spring boot. Remove the version numbers in the dependencies section. The parent pom manages the dependencies for you.

James S
  • 98
  • 3
  • Hi James, thanks for pointing that out, however this is the pom of the independent service /module , there is no parent pom available like the services from which I am migrating few controller,service and impl (which has a parent project and pom, along with 3 services under it), I tried changing 2.6.5 to 2.6.4 at spring-boot-starter-test, but the issue still persists ,apologies if I am being unclear here – kmj Mar 31 '22 at 09:41
  • I was referring to spring-boot-starter-parent but had not noticed that it was commented out. If you enable it then you will get version management along with auto configuration. I recommend spring tool suite for inspecting the libraries that are being included. – James S Apr 01 '22 at 01:46
  • This is a relevant section of the docs: https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html#getting-started.first-application.dependencies – James S Apr 01 '22 at 01:58