Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV not loaded in Tomcat

hi all,

I have followed the following page

http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html

to create a simple project in eclipse, and it works (with jre7, opencv2.4.5)

import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Main {
    public static void main(String[] args) {
        System.loadLibrary("opencv_java245");
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }
}

however, when i paste the same code in a helloworld servlet in my tomcat as a war, it does not work with the UnsatisifiedLinkError for the n_eye component at Mat.eye. i hv managed to move the loadLibrary statement to a static block in a separate class

public class OpenCVLoader {
    static {
        System.loadLibrary("opencv_java245");
    }
...
}

The OpenCVLoader class is packed in a jar placed under $(catalina.home}/lib to be loaded on startup automatically. i hv checked in my helloworld servlet that the opencv_java245.dll has successfully loaded into the memory. (i.e. use reflection to list all the loaded library)

it seems that the dll may not be correctly loaded or linked even it is claimed loaded in tomcat. could anyone give me some help?

thanks a lot! Carlos

OpenCV not loaded in Tomcat

hi all,

I have followed the following page

http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html

to create a simple project in eclipse, and it works (with jre7, opencv2.4.5)

import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Main {
    public static void main(String[] args) {
        System.loadLibrary("opencv_java245");
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }
}

however, when i paste the same code in a helloworld servlet in my tomcat (tomcat 6.0.37, same jre, x64) as a war, it does not work with the UnsatisifiedLinkError for the n_eye component at Mat.eye. i hv managed to move the loadLibrary statement to a static block in a separate class

public class OpenCVLoader {
    static {
        System.loadLibrary("opencv_java245");
    }
...
}

The OpenCVLoader class is packed in a jar placed under $(catalina.home}/lib to be loaded on startup automatically. i hv checked in my helloworld servlet that the opencv_java245.dll has successfully loaded into the memory. (i.e. use reflection to list all the loaded library)

it seems that the dll may not be correctly loaded or linked even it is claimed loaded in tomcat. could anyone give me some help?

thanks a lot! lot!

Carlos

click to hide/show revision 3
retagged

updated 2014-03-19 16:04:13 -0600

berak gravatar image

OpenCV not loaded in Tomcat

hi all,

I have followed the following page

http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html

to create a simple project in eclipse, and it works (with jre7, opencv2.4.5)

import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Main {
    public static void main(String[] args) {
        System.loadLibrary("opencv_java245");
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }
}

however, when i paste the same code in a helloworld servlet in my tomcat (tomcat 6.0.37, same jre, x64) as a war, it does not work with the UnsatisifiedLinkError for the n_eye component at Mat.eye. i hv managed to move the loadLibrary statement to a static block in a separate class

public class OpenCVLoader {
    static {
        System.loadLibrary("opencv_java245");
    }
...
}

The OpenCVLoader class is packed in a jar placed under $(catalina.home}/lib to be loaded on startup automatically. i hv checked in my helloworld servlet that the opencv_java245.dll has successfully loaded into the memory. (i.e. use reflection to list all the loaded library)

it seems that the dll may not be correctly loaded or linked even it is claimed loaded in tomcat. could anyone give me some help?

thanks a lot!

Carlos