Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid or corrupt jarfile #47

Closed
algkebab opened this issue Nov 19, 2014 · 5 comments
Closed

Invalid or corrupt jarfile #47

algkebab opened this issue Nov 19, 2014 · 5 comments

Comments

@algkebab
Copy link

Hi again!

My project is making docker image using your plugin. This image is very simple and just contains a jar file and the command to run it. But the problem is that my jar file which were rpoduced by maven and it starts just fine, has different size than the one, copied to docker image. And the one in image cannot be started, image also cannot be run by docker because it says: Error: Invalid or corrupt jarfile maven/dlr-application-0.0.2-SNAPSHOT.jar

This is the size of copied to docker image jar:
-rw-rw-r-- 1 vagrant vagrant 35580429 Nov 18 17:17 dlr-application-0.0.2-SNAPSHOT.jar

And this is the size of the same jar, produced by maven:
-rw-rw-r-- 1 vagrant vagrant 20991343 Nov 18 17:17 dlr-application-0.0.2-SNAPSHOT.jar

so as you can see, first one which is copied by docker-maven-plugin is almost 2 times bigger and does not start.

@rhuss
Copy link
Collaborator

rhuss commented Nov 19, 2014

Can you check the jar file within the docker container ? Or could you look below target/docker/maven and check the jar therein ? Is it the same that you expect ?

Could you post the assembly descriptor how you put the jar file into the container ?

Are you using the maven-shade plugin for creating a fat jar ? Could that be the issue ?

Sorry it's a bit fishing in the dark since I didn't had this issue. Might be also because of the size (everything it transmitted via Docker's REST API) but then I would expect the jar in the container to be smaller not larger ....

@algkebab
Copy link
Author

this is the content of assembly file:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>${docker.container.name}</id>
    <files>
        <file>
            <source>${project.build.directory}/dlr-application-${project.version}.jar</source>
            <outputDirectory>.</outputDirectory>
            <filtered>true</filtered>
        </file>
    </files>
</assembly>

jar within the container is the same as under target/docker/maven but it is the wrong size then produced by maven.

I am using spring-boot-maven-plugin to create an executable jar

@rhuss
Copy link
Collaborator

rhuss commented Nov 19, 2014

So you say that you have two jar files: One directly below target/ and one below target/docker/maven where the one in the docker dir ist larger. Correct ? Can you look into both files with jar and check their content. Maybe you see a difference here ?

At least it sounds that the process of transmitting the jar to the Docker host is not the problem.

Can you switch of the filtered flag ? This enables variables substitution of Maven properties within your jar which you definitely do not want,

Also instead of directly refering to the jar file you can try the following assembly:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>artifact</id>
  <dependencySets>
    <dependencySet>
      <useProjectArtifact>true</useProjectArtifact>
      <includes>
        <include>${project.groupId}:${project.artifactId}</include>
      </includes>
    </dependencySet>
  </dependencySets>
</assembly>

or alternatively instead of using a assemblyDescriptor in your plugin's configuration you can use

<assemblyDescriptorRef>artifcact<assemblyDescriptorRef>

@algkebab
Copy link
Author

assemblyDescriptorRef>artifcact</assemblyDescriptorRef
Put this instead of descriptor and everything worked. I suppose the problem was with my assembly descriptor.

Thank you very much for your help

@rhuss
Copy link
Collaborator

rhuss commented Nov 19, 2014

Good to know ;-)

@rhuss rhuss closed this as completed Nov 19, 2014
leusonmario pushed a commit to leusonmario/docker-maven-plugin that referenced this issue Aug 18, 2018
leusonmario pushed a commit to leusonmario/docker-maven-plugin that referenced this issue Aug 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants