Ask Your Question

Revision history [back]

Carlos, did you find the way to get through the issue? I had same problem, and could solve it fortunately. Here's my guessing and solution, though I'm not an expert of Tomcat and not pretty sure if this guessing is true.

Tomcat has several classloaders, as you probably know. Because JavaVM can load a native library only once, it probably is a good practice to load OpenCV's native library with 'Common' class loader, just like the way you did by putting your OpenCVLoader in $(catalina.home}/lib.

Here, I guess that you might haven't loaded opencv*.jar with same class loader. When I made many try-and-errors to make my servlet work on Tomcat, I finally found putting both of a small loader class (just like yours!) and opencv itself in the $(catalina.home)/lib can solve the UnsatisfiedLinkError problem. I think a class that is loaded by WebApp class loader cannot access a native module that is loaded by Common class loader.

I believe dev team of opencv's java binding should add a loader class (or method) to official opencv releases, to save many servlet developers working with Tomcat.