baghelamit / video-stream-analytics

Apache License 2.0
302 stars 174 forks source link

java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path #2

Closed kleysonr closed 6 years ago

kleysonr commented 6 years ago

After:

Getting the following error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building video-stream-collector 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ video-stream-collector ---
[INFO] Deleting /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/target
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install-file (install-external) @ video-stream-collector ---
[INFO] pom.xml not found in opencv-320.jar
[INFO] Installing /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/lib/opencv/opencv-320.jar to /home/kleysonr/.m2/repository/opencv/opencv/3.2.0/opencv-3.2.0.jar
[INFO] Installing /tmp/mvninstall717465399647818756.pom to /home/kleysonr/.m2/repository/opencv/opencv/3.2.0/opencv-3.2.0.pom
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ video-stream-collector ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ video-stream-collector ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ video-stream-collector ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ video-stream-collector ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ video-stream-collector ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ video-stream-collector ---
[INFO] Building jar: /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/target/video-stream-collector-1.0.0.jar
[INFO] 
[INFO] --- maven-shade-plugin:3.0.0:shade (default) @ video-stream-collector ---
[INFO] Including org.apache.kafka:kafka_2.11:jar:0.10.2.0 in the shaded jar.
[INFO] Including org.apache.kafka:kafka-clients:jar:0.10.2.0 in the shaded jar.
[INFO] Including net.jpountz.lz4:lz4:jar:1.3.0 in the shaded jar.
[INFO] Including org.xerial.snappy:snappy-java:jar:1.1.2.6 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.21 in the shaded jar.
[INFO] Including net.sf.jopt-simple:jopt-simple:jar:5.0.3 in the shaded jar.
[INFO] Including com.yammer.metrics:metrics-core:jar:2.2.0 in the shaded jar.
[INFO] Including org.scala-lang:scala-library:jar:2.11.8 in the shaded jar.
[INFO] Including org.slf4j:slf4j-log4j12:jar:1.7.21 in the shaded jar.
[INFO] Including com.101tec:zkclient:jar:0.10 in the shaded jar.
[INFO] Including org.apache.zookeeper:zookeeper:jar:3.4.9 in the shaded jar.
[INFO] Including org.scala-lang.modules:scala-parser-combinators_2.11:jar:1.0.4 in the shaded jar.
[INFO] Including com.google.code.gson:gson:jar:2.8.0 in the shaded jar.
[INFO] Including commons-lang:commons-lang:jar:2.6 in the shaded jar.
[INFO] Including log4j:log4j:jar:1.2.17 in the shaded jar.
[INFO] Including opencv:opencv:jar:3.2.0 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/target/video-stream-collector-1.0.0.jar with /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/target/video-stream-collector-1.0.0-shaded.jar
[INFO] Dependency-reduced POM written at: /home/kleysonr/git/x/video-stream-analytics/video-stream-collector/dependency-reduced-pom.xml
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ video-stream-collector ---
2017-12-24 08:20:15 INFO  ProducerConfig:180 - ProducerConfig values: 
    acks = all
    batch.size = 20971520
    block.on.buffer.full = false
    bootstrap.servers = [localhost:9092]
    buffer.memory = 33554432
    client.id = 
    compression.type = gzip
    connections.max.idle.ms = 540000
    interceptor.classes = null
    key.serializer = class org.apache.kafka.common.serialization.StringSerializer
    linger.ms = 5
    max.block.ms = 60000
    max.in.flight.requests.per.connection = 5
    max.request.size = 2097152
    metadata.fetch.timeout.ms = 60000
    metadata.max.age.ms = 300000
    metric.reporters = []
    metrics.num.samples = 2
    metrics.sample.window.ms = 30000
    partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
    receive.buffer.bytes = 32768
    reconnect.backoff.ms = 50
    request.timeout.ms = 30000
    retries = 1
    retry.backoff.ms = 100
    sasl.jaas.config = null
    sasl.kerberos.kinit.cmd = /usr/bin/kinit
    sasl.kerberos.min.time.before.relogin = 60000
    sasl.kerberos.service.name = null
    sasl.kerberos.ticket.renew.jitter = 0.05
    sasl.kerberos.ticket.renew.window.factor = 0.8
    sasl.mechanism = GSSAPI
    security.protocol = PLAINTEXT
    send.buffer.bytes = 131072
    ssl.cipher.suites = null
    ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
    ssl.endpoint.identification.algorithm = null
    ssl.key.password = null
    ssl.keymanager.algorithm = SunX509
    ssl.keystore.location = null
    ssl.keystore.password = null
    ssl.keystore.type = JKS
    ssl.protocol = TLS
    ssl.provider = null
    ssl.secure.random.implementation = null
    ssl.trustmanager.algorithm = PKIX
    ssl.truststore.location = null
    ssl.truststore.password = null
    ssl.truststore.type = JKS
    timeout.ms = 30000
    value.serializer = class org.apache.kafka.common.serialization.StringSerializer

2017-12-24 08:20:15 INFO  AppInfoParser:83 - Kafka version : 0.10.2.0
2017-12-24 08:20:15 INFO  AppInfoParser:84 - Kafka commitId : 576d93a8dc0cf421
2017-12-24 08:20:15 INFO  VideoStreamCollector:47 - Total urls to process 1
[WARNING] 
java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at com.iot.video.app.kafka.collector.VideoEventGenerator.<clinit>(VideoEventGenerator.java:43)
    at com.iot.video.app.kafka.collector.VideoStreamCollector.generateIoTEvent(VideoStreamCollector.java:49)
    at com.iot.video.app.kafka.collector.VideoStreamCollector.main(VideoStreamCollector.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
    at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.366 s
[INFO] Finished at: 2017-12-24T08:20:15-02:00
[INFO] Final Memory: 27M/493M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project video-stream-collector: An exception occured while executing the Java class. no opencv_java320 in java.library.path -> [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
kleysonr commented 6 years ago

Just realized in the blog post about the native library.

Thanks.

everettkyle commented 6 years ago

How do you setup the native libraries in Ubuntu?

haihuynhrdf commented 6 years ago

How do you setup the native libraries on Mac?

kleysonr commented 5 years ago

I don't have the code right now, but the following paragraph in the blogpost helped me to fix the bug.

_This application uses OpenCV native libraries (.dll or .so) and loads them using the System.loadLibrary()method. Set the directory path for these native libraries in the system environment variable or pass this path as a command line argument. For example, for a 64-bit Windows machine, the path of the native library file (opencv_java320.dll and opencv_ffmpeg32064.dll) will be {OpenCV Installation Directory} \build\java\x64.

So, somehow I used the System.loadLibrary() to fix the issue.

haihuynhrdf commented 5 years ago

yes, thank you. I could run the app