2

Lets say that I have 4 Maven modules:

-main
 |-core (OpenCV is included here)
 |-web (REST services that should use core services with OpenCV)
 |-app (simple desktop app that also uses OpenCV through core services)

I want to do it like this in order to have one module that deals with image processing and other modules that should use it.

Another hint: I am using Eclipse Mars (4.5.0).

My problem is that when I add OpenCV as native library (in Preferences), I can't compile my code with Maven since its getting errors like this:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.617 s
[INFO] Finished at: 2016-06-26T19:32:48+02:00
[INFO] Final Memory: 14M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project smilecounter.services: Compilation failure: Compilation failure:
[ERROR] Path/Service.java:[1,23] package org.opencv.core does not exist
[ERROR] Path/Service.java:[2,23] package org.opencv.core does not exist
[ERROR] Path/Service.java:[7,17] cannot find symbol
[ERROR] symbol:   class Mat
[ERROR] location: class Service
[ERROR] Path/Service.java:[7,40] cannot find symbol
[ERROR] symbol:   variable CvType
[ERROR] location: class Service
[ERROR] Path/Service.java:[7,26] cannot find symbol
[ERROR] symbol:   variable Mat
[ERROR] location: class Service

When I create class with main method, OpenCV works correctly.

So, I tried another approach: adding maven dependency on project (not the latest version, but still worth try...).

<!-- https://mvnrepository.com/artifact/nu.pattern/opencv -->
<dependency>
    <groupId>nu.pattern</groupId>
    <artifactId>opencv</artifactId>
    <version>2.4.9-4</version>
</dependency>

This time, Maven compilation works fine, and if I have native class in Build Path, it seems to work properly for app module, but web module gives error:

19:53:05,575 ERROR [io.undertow.request] (default task-97) UT005023: Exception handling request to /SC/rest/snapshot/send: org.jboss.resteasy.spi.UnhandledException: java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path

My question is: is it possible to include OpenCV library inside my core-services.jar so I wouldn't have to configure project? How can I configure server (WildFly 10) to properly use this library?

deem
  • 1,252
  • 1
  • 19
  • 38
  • Have you looked at [this](http://stackoverflow.com/questions/35471772/maven-project-fail-to-call-jar-file) question? – techtabu Jun 26 '16 at 18:15
  • If I understand correctly, in this question he wants to create local maven repo. I'm asking if I can somehow embedd this library in my jar so other modules wouldn't even have to know which library `core` is using. – deem Jun 26 '16 at 18:30

0 Answers0