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

Build failure (mvn package) due to missing target file. #21

Closed
sans-github opened this issue Jun 7, 2017 · 2 comments
Closed

Build failure (mvn package) due to missing target file. #21

sans-github opened this issue Jun 7, 2017 · 2 comments

Comments

@sans-github
Copy link

Hello,

I have com.spotify:dockerfifle-maven-plugin:1.3.0 to build a docker container for this spring-boot app.

On mvn package, I get error indicating jar file is missing.

mvn package
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-boot-embedded-tomcat 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spring-boot-embedded-tomcat ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ spring-boot-embedded-tomcat ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/sdas1/OneDrive/computer/next/depot/github/spring-boot-embedded-tomcat/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ spring-boot-embedded-tomcat ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/sdas1/OneDrive/computer/next/depot/github/spring-boot-embedded-tomcat/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ spring-boot-embedded-tomcat ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ spring-boot-embedded-tomcat ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ spring-boot-embedded-tomcat ---
[INFO] Building jar: /Users/sdas1/OneDrive/computer/next/depot/github/spring-boot-embedded-tomcat/target/spring-boot-embedded-tomcat-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.5.3.RELEASE:repackage (default) @ spring-boot-embedded-tomcat ---
[INFO] 
[INFO] --- dockerfile-maven-plugin:1.3.0:build (default) @ spring-boot-embedded-tomcat ---
[INFO] Building Docker context /Users/sdas1/OneDrive/computer/next/depot/github/spring-boot-embedded-tomcat/docker
[INFO] 
[INFO] Image will be built as com-san/spring-boot-embedded-tomcat:0.0.1-SNAPSHOT
[INFO] 
[INFO] Step 1/5 : FROM frolvlad/alpine-oraclejdk8:slim
[INFO] Pulling from frolvlad/alpine-oraclejdk8
[INFO] Digest: sha256:49772b54d8ed36e060d3e20b704d586a1292b243054c968a494b0c3079605ba5
[INFO] Status: Image is up to date for frolvlad/alpine-oraclejdk8:slim
[INFO]  ---> 354831d86a05
[INFO] Step 2/5 : ENV SERVER_PORT 38080
[INFO]  ---> Using cache
[INFO]  ---> ac6e30c94cb5
[INFO] Step 3/5 : EXPOSE $SERVER_PORT
[INFO]  ---> Using cache
[INFO]  ---> 0ade83cbc7ca
[INFO] Step 4/5 : COPY target/spring-boot-embedded-tomcat-0.0.1-SNAPSHOT.jar /
[ERROR] lstat target/spring-boot-embedded-tomcat-0.0.1-SNAPSHOT.jar: no such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.414 s
[INFO] Finished at: 2017-06-07T14:07:29-07:00
[INFO] Final Memory: 43M/738M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.0:build (default) on project spring-boot-embedded-tomcat: Could not build image: lstat target/spring-boot-embedded-tomcat-0.0.1-SNAPSHOT.jar: no such file or directory -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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

Project structure

.
./docker
./docker/docker-compose.yml
./docker/Dockerfile
./pom.xml
./README.md
./spring-boot-embedded-tomcat.iml
./src
./src/main
./src/main/java
./src/main/java/com
./src/main/java/com/spring
./src/main/java/com/spring/boot
./src/main/java/com/spring/boot/app
./src/main/java/com/spring/boot/app/SampleApplication.java
./src/main/java/com/spring/boot/controller
./src/main/java/com/spring/boot/controller/SampleController.java
./src/main/java/com/spring/boot/model
./src/main/java/com/spring/boot/model/SampleRequest.java
./src/main/java/com/spring/boot/model/SampleResponse.java
./src/main/resources
./src/main/resources/application.properties

build plugin inside pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.5.3.RELEASE</version>
        </plugin>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>dockerfile-maven-plugin</artifactId>
            <version>1.3.0</version>
            <executions>
                <execution>
                    <id>default</id>
                    <goals>
                        <goal>build</goal>
                        <goal>push</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <repository>com-san/spring-boot-embedded-tomcat</repository>
                <tag>${project.version}</tag>
                <contextDirectory>docker</contextDirectory>
                <retryCount>0</retryCount>
            </configuration>
        </plugin>
    </plugins>
</build>

Dockerfile

FROM frolvlad/alpine-oraclejdk8:slim

ENV SERVER_PORT 38080
EXPOSE $SERVER_PORT

COPY target/spring-boot-embedded-tomcat-0.0.1-SNAPSHOT.jar /

CMD [ "java", "-jar", "/spring-boot-embedded-tomcat-0.0.1-SNAPSHOT.jar" ]

Project code - https://github.com/mesanjeeb/spring-boot-embedded-tomcat/tree/spotify-dockerfile-plugin

Thanks,
San

@mattnworb
Copy link
Member

<contextDirectory>docker</contextDirectory> tells the plugin to send only that directory to docker for the build, it is the context that the build operates in. If you want to refer to things from target/ in your Dockerfile then you should probably have the Dockerfile as a file in the top-level of your project, so that your whole project is the build context.

@sans-github
Copy link
Author

That answers my issue - thank you.

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

2 participants