简体   繁体   中英

build docker image using graalvm Error: Main entry point class 'app.jar' not found com.oracle.svm.core.util.UserError$UserException

I am trying to build my Docker image using graalvm-ce but it fails showing error as:

As per oracle blog post I have mentioned the Java class also as a starting point but still it fails.

Error: Main entry point class 'app.jar' not found.
com.oracle.svm.core.util.UserError$UserException: Main entry point class 'app.jar' not found.
        at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:260)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:448)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:113)
Error: Image build request failed with exit status 1

Here is my Dockerfile:

#Multi stage docker file

FROM maven:3.6.1-jdk-8 AS build

ENV APP_HOME=/root/dev/app/

COPY src $APP_HOME/src

COPY pom.xml $APP_HOME/

RUN mvn -f $APP_HOME/pom.xml clean package -DskipTests



FROM oracle/graalvm-ce:19.2.0 AS build-aot

RUN ln -s /opt/graalvm-ce-19.2.0 /opt/graalvm
ENV GRAALVM_HOME=/opt/graalvm
ENV JAVA_HOME=/opt/graalvm
ENV PATH=${GRAALVM_HOME}/bin:${PATH}
RUN gu install native-image
COPY --from=build /root/dev/app/target/knative-spring-gke-1.0.jar /app.jar
RUN native-image --no-server -cp -jar app.jar com.arindam.knative.gke.KnativeSpringGkeApplication
#ENTRYPOINT ["./app"]

FROM frolvlad/alpine-glibc
EXPOSE 8080
COPY --from=build-aot /app .
ENTRYPOINT ["./app"]

Any idea? Thanks in advance.

Your command line for native-image contains -cp -jar app.jar . This is interpreted as -jar is the classpath and app.jar is the main class.

I think you wanted native-image --no-server -cp app.jar com.arindam.knative.gke.KnativeSpringGkeApplication .

If HW.class to be compiled, say

native-image HW

not

native-image HW.class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM