Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unsatisfied Link Error - OpenCV Java 3.3.1 - Apache Wildfly 11

HI,

On windows (Server 2012 R2 64 bit) jdk1.8.0_151, OpenCV 3.3.1.jar - I am attempting to run the simplest sample code:

            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
            System.out.println("mat = " + mat.dump());

within a message driven bean:

@MessageDriven(name = "SimpleMessageDrivenBean", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/jms/SimpleQueue"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class SimpleMessageDrivenBean implements MessageListener {
@Override
public void onMessage(Message message) {
    try {
            System.out.println(Core.NATIVE_LIBRARY_NAME);
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
            System.out.println("mat = " + mat.dump());

            System.out.println("Got message: " + ((TextMessage)message).getText() + " @" + System.currentTimeMillis());
        } 
        catch (JMSException e) {
        e.printStackTrace();
        }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }

}

As expected, Upon executing this code, I get a Caused by: java.lang.UnsatisfiedLinkError: no opencv_java331 in java.library.path

Once I place opencv_java331.dll in C:\Windows\ on the server in question, this error changes to:

Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J

which suggests that although the native library has been loaded, it is now failing to load some dependency of the opencv_java331.dll (which I had thought was standalone).

Using the same dll and -Djava.library.path="C:\opencv\build\java\x64" to the same Dll within a J2SE project (under netbeans) works, so this suggests that there is some different behaviour under wildfly.

Can anyone offer any assistance?

Many thanks

Richard