title: java.lang.UnsatisfiedLinkError: Native Library XXX.so already loaded in another classloader
body: <p>I have deployed one web-application, which contains following code.</p>
  
  <pre><code>System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
  </code></pre>
  
  <p>Now, I deployed another web-application which also have same code. When it tries to load library, it throwing following error.</p>
  
  <pre><code>Exception in thread "Thread-143" java.lang.UnsatisfiedLinkError: 
  Native Library /usr/lib/jni/libopencv_java248.so already loaded in
  another classloader
  </code></pre>
  
  <p>I want to run these both application simultaneously.</p>
  
  <p>Till now what I have tried:</p>
  
  <ol>
  <li>Loaded library in one application and caught above exception into another application</li>
  <li>Removed jars from both application and put opencv.jar into Tomcat's classpath(ie in /usr/share/tomcat7/lib).</li>
  </ol>
  
  <p>But none of above worked, any suggestions by which I can do this ?</p>
  
  <p><strong>Edit:</strong> for option two, </p>
  
  <pre><code>System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  </code></pre>
  
  <p>This line works but gets exception when I am actually going to use that library. That is when I do following </p>
  
  <pre><code>Mat mat = Highgui.imread("/tmp/abc.png");
  </code></pre>
  
  <p>And I get this exception</p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J
      at org.opencv.highgui.Highgui.imread_1(Native Method)
      at org.opencv.highgui.Highgui.imread(Highgui.java:362)
  </code></pre>