使用graalvm构建docker映像错误:找不到主入口点类'app.jar'com.oracle.svm.core.util.UserError $ UserException

时间:2019-09-27 15:57:03

标签: java dockerfile graalvm

我正在尝试使用graalvm-ce构建我的Docker映像,但是它无法将错误显示为:

根据oracle博客文章,我也提到Java类作为起点,但仍然失败。

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

这是我的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"]

有什么主意吗?预先感谢。

2 个答案:

答案 0 :(得分:0)

您的native-image命令行包含-cp -jar app.jar。这被解释为-jar是类路径,而app.jar是主类。

我认为您想要native-image --no-server -cp app.jar com.arindam.knative.gke.KnativeSpringGkeApplication

答案 1 :(得分:0)

如果要编译HW.class,说

native-image HW

不是

native-image HW.class