Problem writing in xAR operation; archives contains unclosed entries #171

Closed
sverhagen opened this Issue May 17, 2015 · 17 comments

Projects

None yet

5 participants

@sverhagen
Contributor

As of 0.11.4 we are seeing the following problem:

[INFO] --- docker-maven-plugin:0.11.4:build (dockerize) @ myProject ---
[INFO] DOCKER> Creating image [myCompany/myProject:0.1.0-SNAPSHOT] "myProject"
[INFO] Reading assembly descriptor: E:\myProject\src\build\docker\assembly.xml
[INFO] Building tar: E:\myProject\target\docker\myCompany\myProject\0.1.0-SNAPSHOT\build\maven.tgz
[WARNING] When creating tar entry
org.codehaus.plexus.archiver.ArchiverException: Problem writing to output in xAR operation request to write '732' bytes exceeds size in header of '488' bytes for entry './usr/local/tomcat/webapps/myWebapp/META-INF/MANIFEST.MF'
        at org.codehaus.plexus.archiver.util.Streams.copyFullyDontCloseOutput(Streams.java:122)
        at org.codehaus.plexus.archiver.tar.TarArchiver.tarFile(TarArchiver.java:335)
        at org.codehaus.plexus.archiver.tar.TarArchiver.execute(TarArchiver.java:188)
        at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:930)
        at org.apache.maven.plugin.assembly.archive.archiver.AssemblyProxyArchiver.createArchive(AssemblyProxyArchiver.java:589)
        at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:165)
        at org.jolokia.docker.maven.assembly.DockerAssemblyManager.createAssemblyTarArchive(DockerAssemblyManager.java:177)
        at org.jolokia.docker.maven.assembly.DockerAssemblyManager.createDockerTarArchive(DockerAssemblyManager.java:69)
        at org.jolokia.docker.maven.BuildMojo.buildImage(BuildMojo.java:82)
        at org.jolokia.docker.maven.BuildMojo.executeInternal(BuildMojo.java:64)
        at org.jolokia.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:134)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

And:

[ERROR] Failed to execute goal org.jolokia:docker-maven-plugin:0.11.4:build (dockerize) on project myProject: Failed to create assembly for docker image: Error creating assembly archive docker: This archives contains unclosed entries. -> [Help 1]

Plugin execution as configured in pom.xml:

<plugin>
    <groupId>org.jolokia</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.11.4</version> <!-- NO PROBLEM WITH 0.11.3 -->
    <executions>
        <execution>
            <id>dockerize</id>
            <phase>package</phase>
            <goals>
                <goal>build</goal>
            </goals>
            <configuration>
                <images>
                    <image>
                        <name>myCompany/${project.artifactId}:${project.version}</name>
                        <alias>${project.artifactId}</alias>
                        <build>
                            <from>registry.hub.docker.com/tomcat:7-jre8</from>
                            <ports>
                                <port>8080</port>
                            </ports>
                            <assembly>
                                <basedir>/</basedir>
                                <descriptor>${basedir}/src/build/docker/assembly.xml</descriptor>
                            </assembly>
                        </build>
                    </image>
                </images>
                <registry>my company's registry</registry>
            </configuration>
        </execution>
    </executions>
</plugin>

Assembly as defined in ${basedir}/src/build/docker/assembly.xml:

<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>redacted</id>
    <dependencySets>
        <dependencySet>
            <includes>
                <include>${project.groupId}:${project.artifactId}</include>
            </includes>
            <outputDirectory>/usr/local/tomcat/webapps/myWebapp</outputDirectory>
            <unpack>true</unpack>
            <useProjectArtifact>true</useProjectArtifact>
        </dependencySet>
    </dependencySets>
    <files>
        <file>
            <outputDirectory>/usr/local/tomcat/conf</outputDirectory>
            <source>${basedir}/src/build/docker/context.xml</source>
        </file>
    </files>
</assembly>

This defect may have been introduced by issue #139, although that's just a hunch.

@rhuss rhuss added a commit that referenced this issue May 17, 2015
@rhuss rhuss Changed to use tar instead of tgz as intermeditate format
Try to tackle #171.
23f23c6
@rhuss
Collaborator
rhuss commented May 17, 2015

Yes, thats true. I changed it a bit to use tar instead of tgz as intermediate format and pushed a 0.11.5-SNAPSHOT to Maven central.

Alternatively you can get this change via branch integration.

Does this help ? (hadn't a chance yet to repdroduce it myself)

@sverhagen
Contributor

Thank you for that. I tried a 0.11.5-SNAPSHOT with the following SHA1: f9575b034d576b94194e7814cfb5af8f119b0b19, and it did not resolve my problem. It did not change any of the above behavior.

@rhuss
Collaborator
rhuss commented May 18, 2015

Ok. May I ask to try a third time ? Now I changed from using tar to zip. I just pushed the corresponding snapshot (sha1: 3f81bca7d349af3a6d0c597816b8ce702afbfe3e)

Sorry, but I guess the issue is also connected to the OS (Windows in your case if I'm right) and I don't have a Windows setup (yet).

If this doesn't help, I will try to reproduce the issue so that I can better debug it.

Thanks for your patience ...

@sverhagen
Contributor

Thank you for that. The issue was not limited to Windows, Mac users have seen this happening. I don't think I've seen it happening on any of our CI servers, which are Linux.

I tried the new 0.11.5-SNAPSHOT and it does fix the problem. It seems to create ZIP and a TAR, for what it's worth.

[INFO] --- docker-maven-plugin:0.11.4:build (dockerize) @ myProject ---
[INFO] DOCKER> Creating image [myCompany/myProject:0.1.0-SNAPSHOT] "myProject"
[INFO] Reading assembly descriptor: E:\myProject\src\build\docker\assembly.xml
[INFO] Building zip: E:\myProject\target\docker\myCompany\myProject\0.1.0-SNAPSHOT\build\maven.zip
[INFO] Building tar: E:\myProject\target\docker\myCompany\myProject\0.1.0-SNAPSHOT\tmp\docker-build.tar

It would be great to get this in a released version!

@sverhagen
Contributor

I also just noticed that at the end of the build, there's a message now:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:55 min
[INFO] Finished at: 2015-05-17T23:33:36-07:00
[INFO] Final Memory: 125M/588M
[INFO] ------------------------------------------------------------------------
Cleaning up unclosed ZipFile for archive E:\myProject\target\docker\myCompany\myProject\0.1.0-SNAPSHOT\build\maven.zip
@rhuss
Collaborator
rhuss commented May 18, 2015

Thanks, for confirming that it works. I indeed make this configurable, so that you can even use the "old" variant without an intermediate archive (but by copying directories). The advantage of using an archive is that file permissions should be better preserved because they are then independent on the underlying filesystem (that's the theory :).

I will also take care of cleaning up the zip-file. fwiw, I plan a 0.11.5 release this week with this fix + fixed registry handling.

@sverhagen
Contributor

Sounds good, a release this week, particularly if that were to include more goodies that I look forward to 😄 (#146?)

@rhuss
Collaborator
rhuss commented May 18, 2015

#146 is already fixed (but not yet pushed, need some better testing yet)

@rhuss rhuss added this to the 0.11.5 milestone May 18, 2015
@rhuss rhuss added the bug label May 18, 2015
@rhuss
Collaborator
rhuss commented May 18, 2015

The zip file issue is probably due to this bug: https://jira.codehaus.org/browse/MASSEMBLY-742 We probably have to wait until this is fixed.

@rhuss rhuss added a commit that referenced this issue May 18, 2015
@rhuss rhuss Make assembly file container format configurable
This can be specified with <build><assembly><mode>...</....> where
mode can be "dir", "tar", "tgz" or "zip". Fixes #171.

Still todo: Allow configuraton over property, too.
31b247d
@rhuss rhuss added a commit that closed this issue May 18, 2015
@rhuss rhuss Changed intermediate build archive from tar to zip
Hopefully this fixes #171.
df05114
@rhuss rhuss closed this in df05114 May 18, 2015
@dverbeek84

@rhuss can you update maven-assambly-plugin? white 2.5.3 i don't get the stacktrace but a error message. Now it is saying A tar file cannot include itself. This is because i am using the project root folder. @sverhagen is this also your problem?

@arthurtsang

@rhuss i'm using 0.14.1 and have the same issue as @dverbeek84. the same setup works in 0.13.9 (having the Dockerfile in the project root. looks like it's tar-ing up target while writing it's output under target?

@vrenjith

Roland,

Do you why this issue is happening again? I am using 0.14.0.

<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.14.0</version>
[WARNING] When creating tar entry
org.codehaus.plexus.archiver.ArchiverException: Problem writing to output in xAR operation request to write '8192' bytes exceeds size in header of '755826688' bytes for entry 'target/docker/registry.mo.test/5002/sampleapp/service/tmp/docker-build.tar'
    at org.codehaus.plexus.archiver.util.Streams.copyFullyDontCloseOutput(Streams.java:122)
    at org.codehaus.plexus.archiver.tar.TarArchiver.tarFile(TarArchiver.java:318)
    at org.codehaus.plexus.archiver.tar.TarArchiver.execute(TarArchiver.java:171)
    at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:916)
    at io.fabric8.maven.docker.assembly.DockerAssemblyManager.createBuildTarBall(DockerAssemblyManager.java:183)
    at io.fabric8.maven.docker.assembly.DockerAssemblyManager.createDockerTarArchive(DockerAssemblyManager.java:93)
    at io.fabric8.maven.docker.service.ArchiveService.createArchive(ArchiveService.java:102)
    at io.fabric8.maven.docker.service.BuildService.buildImage(BuildService.java:48)
    at io.fabric8.maven.docker.AbstractBuildSupportMojo.buildImage(AbstractBuildSupportMojo.java:63)
    at io.fabric8.maven.docker.BuildMojo.buildAndTag(BuildMojo.java:46)
    at io.fabric8.maven.docker.BuildMojo.executeInternal(BuildMojo.java:38)
    at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:164)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
@rhuss
Collaborator
rhuss commented May 30, 2016

@vrenjith could you update to d-m-p 0.15.3 (which is the latest version) ? If the problem then still persists, could you please post your build condiguration ?

thanks ...

@vrenjith

Unfortunately it still fails with 0.15.3

[INFO] Building tar: /home/vagrant/SampleApp/greeting-service/target/docker/registry.mo.sap.corp/5002/ariba-sampleapp/greeting-service/tmp/docker-build.tar
[WARNING] When creating tar entry
org.codehaus.plexus.archiver.ArchiverException: Problem writing to output in xAR operation request to write '8192' bytes exceeds size in header of '755826688' bytes for entry 'target/docker/registry.mo.sap.corp/5002/ariba-sampleapp/greeting-service/tmp/docker-build.tar'
    at org.codehaus.plexus.archiver.util.Streams.copyFullyDontCloseOutput(Streams.java:122)
    at org.codehaus.plexus.archiver.tar.TarArchiver.tarFile(TarArchiver.java:318)
    at org.codehaus.plexus.archiver.tar.TarArchiver.execute(TarArchiver.java:171)
    at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:916)
    at io.fabric8.maven.docker.assembly.DockerAssemblyManager.createBuildTarBall(DockerAssemblyManager.java:188)
    at io.fabric8.maven.docker.assembly.DockerAssemblyManager.createDockerTarArchive(DockerAssemblyManager.java:113)
@rhuss
Collaborator
rhuss commented May 30, 2016

Can you please post your configuration ?

@vrenjith
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                    <!-- <executable>true</executable> -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.15.3</version>
                <configuration>
                    <images>
                        <image>
                            <alias>greeting-service-${maven.build.timestamp}</alias>
                            <name>${localregistry}/${docker.image.prefix}/greeting-service</name>
                            <build>
                                <assembly>
                                    <descriptorRef>artifact</descriptorRef>
                                    <dockerFileDir>${project.basedir}/.</dockerFileDir>
                                </assembly>
                            </build>
                            <run>
                                <namingStrategy>alias</namingStrategy>
                                                                <envPropertyFile>/home/vagrant/SampleApp/cobalt/LocalEnv</envPropertyFile>
                                <net>pod-network</net>
                                <ports>
                                    <port>8000:8080</port>
                                </ports>
                            </run>
                        </image>
                    </images>
                </configuration>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>build</goal>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
@rhuss
Collaborator
rhuss commented May 30, 2016

@vrenjith first of all, it doesn't make sense to use both, dockerFileDir and descriptorRef, since these are different methods for creating docker images.

Then if, you use basedir as the place for the Dockerfile, you also include the target/ directory in the docker build context. That is what ends up in a docker tar archive, so the archive itself is put into this context.

The solution is to either move your Dockerfile in a separate directory (e.g. src/docker) or you add a file .maven-dockerignore including target/**. See also #397.

Does this help ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment