зеркало из https://github.com/Azure/draft-classic.git
Build error and runtime errors with Java pack fixed
1) The artifact name built was helloworld.jar but the copy command was referring to different name hence build is failing: ``` Step 6/8 : COPY --from=BUILD /usr/src/app/target/app.jar /opt/app.jar lstat usr/src/app/target/app.jar: no such file or directory ``` Fixed by copying helloworld.jar instead of app.jar 2) Since the jar being deployed was a thin jar without dependencies, it was not able to find Spark classes and thus failing: ``` 2017-07-03T10:23:49.370518638Z Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: spark/Request 2017-07-03T10:23:49.373134679Z at helloworld.Hello.main(Hello.java:7) 2017-07-03T10:23:49.373163432Z Caused by: java.lang.NoClassDefFoundError: spark/Request 2017-07-03T10:23:49.373167578Z ... 1 more 2017-07-03T10:23:49.373170484Z Caused by: java.lang.ClassNotFoundException: spark.Request 2017-07-03T10:23:49.373173097Z at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 2017-07-03T10:23:49.373175661Z at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 2017-07-03T10:23:49.373178321Z at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) 2017-07-03T10:23:49.373180932Z at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 2017-07-03T10:23:49.373183512Z ... 1 more ``` Fixed by using the "-with-dependency" jar
This commit is contained in:
Родитель
c4a863536d
Коммит
d82ec4edde
|
@ -5,6 +5,6 @@ RUN mvn -f /usr/src/app/pom.xml clean package
|
|||
|
||||
FROM openjdk:8-jdk-alpine
|
||||
EXPOSE 4567
|
||||
COPY --from=BUILD /usr/src/app/target/app.jar /opt/app.jar
|
||||
COPY --from=BUILD /usr/src/app/target/helloworld-jar-with-dependencies.jar /opt/app.jar
|
||||
WORKDIR /opt
|
||||
CMD ["java", "-jar", "app.jar"]
|
||||
|
|
Загрузка…
Ссылка в новой задаче