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.

Error: Invalid or corrupt jarfile /app.jar

See original GitHub issue

I have setup the following Dockerfile. Everything seems to build fine but getting the error that it is corrupt. I did verify that java 8 is set in the POM and manually executed the jar so I know it is working. The other change is that I moved the Dockerfile to the project root. Docker complains about any type of ../ being used to get a path.

Should this work?

FROM dockerfile/java:oracle-java8
VOLUME /tmp
ADD target/core-0.1.0-RELEASE.jar app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=local","/app.jar"]

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
ccit-spencecommented, Apr 13, 2015

ok, got it to work.

FROM dockerfile/java:oracle-java8
VOLUME /tmp
ADD target/core-0.1.0-RELEASE.jar target/app.jar
RUN bash -c 'touch target/app.jar'
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=local","target/app.jar"]
3reactions
givenmcommented, Oct 29, 2018

For me when I was having the issue, all I did was put the JAR_FILE argument in the pom without the forward slash “/” and it worked.

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.2.0</version>
                <configuration>
                    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                    <imageTags>
                        <imageTag>${project.version}</imageTag>
                        <imageTag>latest</imageTag>
                    </imageTags>
                    <!-- optionally overwrite tags every time image is built with docker:build -->
                    <forceTags>true</forceTags>
                    <dockerDirectory>src/main/docker</dockerDirectory>
                    <buildArgs>
                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>
    </build>

Also my Dockerfile is like below


FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Run SpringBoot-based docker image return error message ...
spring boot - Run SpringBoot-based docker image return error message:Invalid or corrupt jarfile /app. jar - Stack Overflow. Stack Overflow for Teams –...
Read more >
1798079 – Multistage Docker File - Error: Invalid or corrupt jarfile
Description of problem: I have a Multistage docker file for a spring-boot java application, that when built locally the image runs successfully.
Read more >
"Invalid or corrupt jarfile export.jar..." while the export utility
This issue occurs when the Java version installed in your machine is not version 8. Solution.
Read more >
Error: Invald or corrupt Jarfile /app.jar : r/docker - Reddit
Is it valid to give a file name as the second parameter instead of a location? COPY ${JAR_FILE} app.jar. Might be worth to...
Read more >
Docker Error :Invalid or corrupt jarfile .jar_穿越23小时的博客
他提示的是你的jar包有问题,无效。那么有很多种情况,我遇到的是两种。dockerfile有问题,我的dockerfile一开始是直接网上复制的,其中有一句是将jar ...
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