1

Since the Bintray and JCenter sunset, I am facing issue with CI/CD Pipeline build. I identified the issue and fixed it with the help of stackoverflow user by including additional repositories.

Now after adding new repositories, I am facing issue with dependencies for spring-data-jpa (especially hibernate-core and persistence api is not working and I see compile time error). While running mvn clean install command, I got the error package javax.persistence not found. Project structure is multi-module with a parent and many Child module as below -

Parent pom

<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.demo</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>sfv</name>
    <url>http://maven.apache.org</url>
    <modules>
        <module>mysql-db</module>
        <module>demo-util</module>

    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <spring.boot.version>1.3.3.RELEASE</spring.boot.version>
        <spring.version>4.2.5.RELEASE</spring.version>
        <aws.version>1.9.22</aws.version>
        <searchbox.version>2.0.0</searchbox.version>
        <mysql.version>5.1.38</mysql.version>
        <ehcache.version>2.10.1</ehcache.version>
        <commons.net.version>2.0</commons.net.version>
        <thumbnailator.version>0.4.8</thumbnailator.version>
        <google.api.version>v4-rev9-1.22.0</google.api.version>
        <gson.client.version>1.21.0</gson.client.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Brixton.RELEASE</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>${spring.boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Brixton.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>central</id>
            <name>bintray</name>
            <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-repo</id>
            <name>Spring Repository</name>
            <url>https://repo.spring.io/release</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>maven-central</id>
            <name>Maven Central</name>
            <url>https://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.4</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.sfv.App</mainClass>
                    <arguments>
                        <argument>argument1</argument>
                    </arguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jfrog.buildinfo</groupId>
                <artifactId>artifactory-maven-plugin</artifactId>
                <inherited>false</inherited>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.1</version>

                <configuration>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                    </archive>
                </configuration>
            </plugin>
        </plugins>

    </build>
</project>

mysql-db pom -

<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.demo.db.mysql</groupId>
    <artifactId>mysql-db</artifactId>
    <packaging>jar</packaging>

    <name>mysql-db</name>
    <url>http://maven.apache.org</url>

    <parent>
        <groupId>com.demo</groupId>
        <artifactId>demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>
        
    </dependencies>

</project>

All dependency for util and mysql project started breaking somehow. I tried to include missing versions but seems as I fix one, the list keep on growing. For example, to fix javax.persistence error I include below two dependency -

<dependency>
                <groupId>javax.persistence</groupId>
                <artifactId>javax.persistence-api</artifactId>
  
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>

            </dependency>

But further, in the util project, I got slf4j dependency error. These dependency previous was provided by spring-boot-starter-data-jpa, but not working anymore since moving away from Bintray.

Adeel Ahmad
  • 185
  • 1
  • 17
  • 1
    Why are you using very old version that are no longer supported? – Simon Martinelli May 03 '21 at 06:22
  • those were the spring dependencies released at the time project was started. Overnight I cannot upgrade them as a risk it might break the functionality of system. – Adeel Ahmad May 03 '21 at 06:28
  • I have another thread where it all started. https://stackoverflow.com/questions/67353462/maven-spring-boot-and-spring-cloud-pom-dependency-not-found/67353516?noredirect=1#comment119051175_67353516 – Adeel Ahmad May 03 '21 at 06:29
  • I had to change Bintray recently. Didn't know it the impact and what it will take to fix them – Adeel Ahmad May 03 '21 at 06:31
  • Upgrading to new version is not the answer for me at the point as it will require some changes in the way JPA query is written in my project. Although that would be next goal for me – Adeel Ahmad May 03 '21 at 06:32
  • With maven central defined as one of the repositories, you should be able to get all the dependencies. Does the build fail only on CI pipeline or local as well? – GSSwain May 03 '21 at 07:49

2 Answers2

0

Fortunately, this issue was not related to dependency management but artifactory server. I am managing internal artifactory server which is primary source of repositories.

While using mvn clean install command the error was misleading to dependency issue but the actual issue was Artifactory Server Storage failure which lead to unresolved dependency. Storage space was full on Artifactory server due to which download operations were also impacted. To resolve this error, we added extra volume to the server and it started working fine there after.

Adeel Ahmad
  • 185
  • 1
  • 17
0

I also got following error with Javax.persistence library

Failed to read artifact descriptor for javax.persistence:javax.persistence-api:jar:2.2: Could not transfer artifact javax.persistence:javax.persistence-api:pom:2.2 from/to spring-milestones (https://repo.spring.io/milestone): transfer failed for https://repo.spring.io/milestone/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.pom:

I have deleted the target folder of the project. After that, I have executed mvn clean install

It build successfully afterward in my case.