Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Plugin doesn't work on Windows - wrong path handling #68

Closed
krystiannowak opened this issue Apr 9, 2015 · 17 comments
Closed

Plugin doesn't work on Windows - wrong path handling #68

krystiannowak opened this issue Apr 9, 2015 · 17 comments

Comments

@krystiannowak
Copy link

Running the plugin on Windows (yes...) ends with following error (stacktrace enabled):

[INFO] --- docker-maven-plugin:0.2.5:build (build) @ my-service ---
[INFO] Copying c:\devel\myorg\cc\my-service\target\my-service-war-exec.jar -> c:\devel\myorg\cc\my-service\target\docker\my-service-war-exec.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.007s
[INFO] Finished at: Thu Apr 09 22:22:05 CEST 2015
[INFO] Final Memory: 35M/346M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.2.5:build (build) on project my-service: Exception caught: UNC path is missing sharename: /\my-service-war-exec.jar -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:0.2.5:build (build) on project my-service: Exception caught
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        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:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        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:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught
        at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:65)
        at com.spotify.docker.BuildMojo.execute(BuildMojo.java:79)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: java.nio.file.InvalidPathException: UNC path is missing sharename: /\my-service-war-exec.jar
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:118)
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
        at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
        at java.nio.file.Paths.get(Paths.java:84)
        at com.spotify.docker.BuildMojo.copyResources(BuildMojo.java:570)
        at com.spotify.docker.BuildMojo.execute(BuildMojo.java:254)
        at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:63)
        ... 22 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
c:\devel\myorg\cc\my-service>

Plugin configuration used for that project is as follows:

<configuration>
    <baseImage>${docker-registry}/lightweight/oracle-java-7-debian</baseImage>
    <cmd>java -jar /${project.name}-war-exec.jar</cmd>
    <exposes>
        <expose>8080</expose>
    </exposes>
    <resources>
        <resource>
            <targetPath>/</targetPath>
            <directory>${project.build.directory}</directory>
            <include>${project.build.finalName}-war-exec.jar</include>
        </resource>
    </resources>
</configuration>
@arghya88
Copy link

remove targetPath tag

@chrisdostert
Copy link

@arghya88 your suggestion worked great for me

@rharido
Copy link

rharido commented Jun 24, 2015

If you want to copy your resources to a specific folder in the docker image you will need targetPath. In this case it is still a problem.
/opt/${project.artifactId} -- Fails in windows

@rohansingh
Copy link
Contributor

What happens if you use backslashes in the targetPath?

@sellersj
Copy link

sellersj commented Jul 8, 2015

I'm running into this issue too on version 0.2.11. I've tried:
/
${file.separator}
/
/

//

Any helpers or work arounds would be great.

@sellersj
Copy link

sellersj commented Jul 9, 2015

I have not tested it yet, but it looks like someone has made a fix. It's waiting in a PR
https://github.com/oberthur/docker-maven-plugin/commit/1f303e0aeb76aee5122d6d7bda4cd240518a6337

@sellersj
Copy link

sellersj commented Jul 9, 2015

I've now tested oberthur's fork and it works for me on windows. The change is in #65

@BrettFieber
Copy link

In case you can't wait for that PR, here is a workaround I came up with:

<!-- define a default value in <properties> ->
<properties>
    ...
    <docker.resource.targetPath>/</docker.resource.targetPath>
</properties>

<!-- define a profile that is activated in windows environments -->
<profiles>
    <profile>
        <id>windows</id>
        <activation>
            <os>
                <family>Windows</family>
            </os>
        </activation>
        <properties>
            <docker.resource.targetPath></docker.resource.targetPath>
        </properties>
    </profile>
</profiles>

<!-- then set the targetPath using the property -->
<build>
    <plugins>
        <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.2.12</version>
                <configuration>
                    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                    <dockerDirectory>src/main/docker</dockerDirectory>
                    <resources>
                       <resource>
                           <targetPath>${docker.resource.targetPath}</targetPath>
                           <directory>${project.build.directory}</directory>
                           <include>${project.build.finalName}.jar</include>
 ...

Hope this helps.

@pmandayam
Copy link

@BrettFieber this worked for me, thanks

@davidxia
Copy link
Contributor

This should be resolved by https://github.com/spotify/docker-maven-plugin/pull/121/commits

@javacody
Copy link

I just tried this with 0.3.5 on Windows. It's still broken.

@sellersj
Copy link

Not that it helps for the spotify plugin, but one I've found that works on windows is https://github.com/rhuss/docker-maven-plugin

Good luck.

@rohansingh
Copy link
Contributor

Reopening this based on reports that it doesn't work. We welcome PR's but are unlikely to fix this at Spotify, since nobody has a Windows setup to test it out with.

@rohansingh rohansingh reopened this Nov 23, 2015
@craykg
Copy link
Contributor

craykg commented Dec 9, 2015

I ran into this same issue, and have created a PR that works around the issue (its actually a bug in the Windows implementation of Paths.get)

@mattnworb
Copy link
Member

@javacody do you still have issues with 0.3.9-SNAPSHOT? If so can you tell us the output of running your maven commands with the -e flag?

@sunieldalal
Copy link

I was facing the same issue. Upgraded to 0.3.9 version and no longer facing the issue.

@mattnworb
Copy link
Member

@sunieldalal thanks for the confirmation!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests