Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 1908
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T07:10:37+00:00 2022-05-31T07:10:37+00:00

java – Problems using a rest api .jar in docker

  • 0

[ad_1]

Basically, I added code to an already existing REST API (java, Springboot). when I run it on Intellij there’s no problem and I can use it as intended.
The thing is that I want to test it on a Docker container.
I builded the .jar of the project by using
Build->Build Artifact->project_name.jar->Build
and when I try to docker-compose up I get several problems.

The folder I use contains : a docker-compose.yml, a Dockerfile, and the .jar
I know the first two files are ok as I used them to run a small test project and had no errors.

The first problem I got when building the container is :
no main manifest attribute, in /project_name.jar

My MANIFEST.MF look like this in my IDE :

Manifest-Version: 1.0
Main-Class: com.project.project_name.adapters.api.Application

but in my .jar artifact look like this :

Manifest-Version: 1.0
Implementation-Title: spring-beans
Automatic-Module-Name: spring.beans
Implementation-Version: 5.2.3.RELEASE
Created-By: 1.8.0_232 (Oracle Corporation)

So my first question is why is it different and why is it deleting the part with the Main Class ? And of course how to solve this problem ?

As a temporary solution, I added the Main Class in the MANIFEST.MF by hand in my .jar

By doing so, I get a MANIFEST.MF that look like this :

Manifest-Version: 1.0
Main-Class: com.project.project_name.adapters.api.Application
Implementation-Title: spring-beans
Automatic-Module-Name: spring.beans
Implementation-Version: 5.2.3.RELEASE
Created-By: 1.8.0_232 (Oracle Corporation)

When I try to docker-compose up once again, I get this error :
java.lang.IllegalArgumentException: No auto configuration classes found in META -INF/spring.factories. If you are using a custom packaging, make sure that file is correct.

I’m not really a pro in Springboot, and that’s an ex-coworker who did the first part of the project, but I’m pretty sure it uses custom packaging.

the file spring.factories look like this :

org.springframework.beans.BeanInfoFactory=org.springframework.beans.ExtendedBeanInfoFactory

and I don’t know if this is supposed to be correct or not.
I’m clearly missing something but I don’t really know what, even after looking here for similar problem and potential solution, but nothing did the trick.

Just in case here’s 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.piroux</groupId>
    <artifactId>phoenixrh-backend</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>10</source>
                    <target>10</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.piroux.phoenixrhbackend.adapters.api.Application</mainClass>
                </configuration>
                <version>2.1.4.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.2.4.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>de.bechte.junit</groupId>
            <artifactId>junit-hierarchicalcontextrunner</artifactId>
            <version>4.12.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.45</version>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>1.14.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>mysql</artifactId>
            <version>1.14.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

Not sure if any other information is needed, but if so just tell me.

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 5379 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1169 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1111 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.