Closed etherny closed 6 years ago
to add more information on that, we tried two thing to get similar thing done with no success:
execstack
on it but since the /tmp/xxx/libopencv_java400.so
file is made accessible at build time and not run time, then in the docker running the jar we cannot reach this .so file.Also please note the warning is blocking the execution since we then encounter:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at clojure.lang.RT.classForName(RT.java:2168)
at clojure.lang.RT.classForName(RT.java:2177)
at clojure.lang.RT.loadClassForName(RT.java:2196)
at clojure.lang.RT.load(RT.java:443)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5677.invoke(core.clj:5893)
at clojure.core$load.invokeStatic(core.clj:5892)
at clojure.core$load.doInvoke(core.clj:5876)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5697)
at clojure.core$load_one.invoke(core.clj:5692)
at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
at clojure.core$load_lib.invokeStatic(core.clj:5736)
at clojure.core$load_lib.doInvoke(core.clj:5717)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$load_libs.invokeStatic(core.clj:5774)
at clojure.core$load_libs.doInvoke(core.clj:5758)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$require.invokeStatic(core.clj:5796)
at clojure.core$require.doInvoke(core.clj:5796)
at clojure.lang.RestFn.invoke(RestFn.java:457)
at indexation.image_processing$loading__5569__auto____36.invoke(image_processing.clj:1)
at indexation.image_processing__init.load(Unknown Source)
at indexation.image_processing__init.<clinit>(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at clojure.lang.RT.classForName(RT.java:2168)
at clojure.lang.RT.classForName(RT.java:2177)
at clojure.lang.RT.loadClassForName(RT.java:2196)
at clojure.lang.RT.load(RT.java:443)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5677.invoke(core.clj:5893)
at clojure.core$load.invokeStatic(core.clj:5892)
at clojure.core$load.doInvoke(core.clj:5876)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:379)
at clojure.lang.Util.loadWithClass(Util.java:250)
at indexation.image_processing.<clinit>(Unknown Source)
Caused by: java.io.IOException: Couldn't load library library opencv_java400
at org.scijava.nativelib.NativeLoader.loadLibrary(NativeLoader.java:141)
at opencv4.core__init.load(Unknown Source)
at opencv4.core__init.<clinit>(Unknown Source)
... 42 more
Please also note we tried to run with CMD java -jar backend-standalone.jar -z noexecstack
with not more success
Hi there,
not sure how you are creating your fat jar, there is a sample Dockerfile in the sibling test project: https://github.com/hellonico/origami_samples_libc2_19/
It uses a more compatible native jar, so with leiningen:
[opencv/opencv-native-ubuntu16-noffmpeg "4.0.0-beta"]
or maven:
<dependency>
<groupId>opencv</groupId>
<artifactId>opencv-native-ubuntu16-noffmpeg</artifactId>
<version>4.0.0-beta</version>
</dependency>
I just deployed a new version of origami (4.0.0-beta7) making that opencv-native version the default.
I took the opportunity to deprecate the above project, so you can just have a look at the samples project.
Some docker instructions are here: https://github.com/hellonico/origami_samples#docker
by the way, I'd be super happy if there were any examples you could share ;)
Same issue
Hello, i m using embaded jar, not lein command in docker image.
Here my project file :
(defproject indexation "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:repositories [["vendredi" "https://repository.hellonico.info/repository/hellonico/"]]
:dependencies [[org.clojure/clojure "1.9.0"]
[origami "4.0.0-beta7"]
[opencv/opencv-native-libc_2_19 "4.0.0-beta"]
[org.clojure/clojure "1.9.0"]]
:main indexation.image-processing)
Here the code
(ns indexation.image-processing
(:gen-class)
(:require [opencv4.core :refer [imread resize! new-size imwrite]]))
(defn resize-keep-ratio! [mat new-width]
(let [size (.size mat)
width (.width size)
height (.height size)
ratio (/ width height)
new-height (/ new-width ratio)]
(println "Image from" width "x" height "to" new-width "x" new-height)
(resize! mat (new-size new-width new-height))))
;
(defn -main [& args]
(time (-> "resources/photo.jpg"
(imread)
(resize-keep-ratio! 300)
(imwrite "resources/output.png"))))
Dockerfile
FROM openjdk:jdk
COPY indexation-0.1.0-SNAPSHOT-standalone.jar indexation.jar
COPY resources resources
Docker image building :
OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/nativelib-loader_8297043941214514255/libopencv_java400.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at clojure.lang.RT.classForName(RT.java:2204)
at clojure.lang.RT.classForName(RT.java:2213)
at clojure.lang.RT.loadClassForName(RT.java:2232)
at clojure.lang.RT.load(RT.java:450)
at clojure.lang.RT.load(RT.java:426)
at clojure.core$load$fn__6548.invoke(core.clj:6046)
at clojure.core$load.invokeStatic(core.clj:6045)
at clojure.core$load.doInvoke(core.clj:6029)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5848)
at clojure.core$load_one.invoke(core.clj:5843)
at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
at clojure.core$load_lib.invokeStatic(core.clj:5887)
at clojure.core$load_lib.doInvoke(core.clj:5868)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$load_libs.invokeStatic(core.clj:5925)
at clojure.core$load_libs.doInvoke(core.clj:5909)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$require.invokeStatic(core.clj:5947)
at clojure.core$require.doInvoke(core.clj:5947)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at indexation.image_processing$loading__6434__auto____180.invoke(image_processing.clj:1)
at indexation.image_processing__init.load(Unknown Source)
at indexation.image_processing__init.<clinit>(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at clojure.lang.RT.classForName(RT.java:2204)
at clojure.lang.RT.classForName(RT.java:2213)
at clojure.lang.RT.loadClassForName(RT.java:2232)
at clojure.lang.RT.load(RT.java:450)
at clojure.lang.RT.load(RT.java:426)
at clojure.core$load$fn__6548.invoke(core.clj:6046)
at clojure.core$load.invokeStatic(core.clj:6045)
at clojure.core$load.doInvoke(core.clj:6029)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:381)
at clojure.lang.Util.loadWithClass(Util.java:250)
at indexation.image_processing.<clinit>(Unknown Source)
Caused by: java.io.IOException: Couldn't load library library opencv_java400
at org.scijava.nativelib.NativeLoader.loadLibrary(NativeLoader.java:141)
at opencv4.core__init.load(Unknown Source)
at opencv4.core__init.<clinit>(Unknown Source)
... 42 more
Thanks for the feedback.
Sorry my explanation was not clear. You don' t need to use this anymore:
[opencv/opencv-native-libc_2_19 "4.0.0-beta"]
just remove it from your project.clj file.
I have created a repository with two docker files: https://github.com/hellonico/origami-indexation
Hope it works for you.
You are very responsive, i will try.
It's working, thank you for your job !
Hello i try to use the lib in docker container and i receive this error :
Here the docker file
Command line :
docker run backend java -jar indexation.jar
PS: the indexation.jar works ouside of docker