Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未满足链接错误:opencv_java2411.dll已加载到glass fish中的另一个类加载器中_Java_Opencv_Classloader_Native_Unsatisfiedlinkerror - Fatal编程技术网

未满足链接错误:opencv_java2411.dll已加载到glass fish中的另一个类加载器中

未满足链接错误:opencv_java2411.dll已加载到glass fish中的另一个类加载器中,java,opencv,classloader,native,unsatisfiedlinkerror,Java,Opencv,Classloader,Native,Unsatisfiedlinkerror,我正在使用opencv用java实现一个用于人脸识别的web应用程序。 当我运行人脸识别代码时,我会遇到如下错误 java.lang.UnsatisfiedLinkError: Native Library F:\opencv\build\java\x86\opencv_java2411.dll already loaded in another classloader 我已经做了一些在internet上可用的方法,例如检查类是否已加载,将system.loadlibrary作为静态块添加到环

我正在使用opencv用java实现一个用于人脸识别的web应用程序。 当我运行人脸识别代码时,我会遇到如下错误

java.lang.UnsatisfiedLinkError: Native Library F:\opencv\build\java\x86\opencv_java2411.dll already loaded in another classloader
我已经做了一些在internet上可用的方法,例如检查类是否已加载,将system.loadlibrary作为静态块添加到环境变量的路径等,但在所有这些过程之后,错误仍然存在于系统中

does anyone has the solution for this problem i am able to run with this dll in desktop application but while running in web application the error comes 

i am running this project using glassfish server on netbeans ide 



public class FaceRecognition {
   public static boolean loaded = false;


 public void loadLib(){
     System.out.println("loading library");
     try {
       System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
     }catch(Exception e){}
        loaded = true;
 }

    public FaceRecognition() {

    }



    public void  saveFaceRecognizedImage(File file){


        try {
            MatOfByte mem = new MatOfByte();

            CascadeClassifier faceDetector = new CascadeClassifier(facerecog.FaceRecognition.class.getResource("haarcascade_frontalface_alt.xml").getPath().substring(1));
            MatOfRect faceDetections = new MatOfRect();

            BufferedImage bi = ImageIO.read(file);
            Mat frame = bufferedImageToMat(bi);


            Rect rectcrop = null;
            faceDetector.detectMultiScale(frame, faceDetections);
            for (Rect rect : faceDetections.toArray()) {
                System.out.println("ttt");
                Core.rectangle(frame, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
                        new Scalar(0, 255,0));
                 rectcrop = new Rect(rect.x,rect.y,120,120);
            }
             try {
                                Mat imgrr = new Mat(frame,rectcrop);
                                Highgui.imwrite(file.getAbsolutePath(), imgrr);
//                                BufferedImage image = ImageIO.read(file);
//                                 BufferedImage scaled = getScaledInstance(
//            image, 120,120, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
//        writeJPG(scaled, new FileOutputStream(file.getAbsolutePath()), 0.85f);
                            }catch(Exception e){}


//            Highgui.imencode(".bmp", frame, mem);
//            Image im = ImageIO.read(new ByteArrayInputStream(mem.toArray()));
//            BufferedImage buff = (BufferedImage) im;
//            ImageIO.write(buff,"jpg",file);
        } catch (IOException ex) {
            Logger.getLogger(FaceRecognition.class.getName()).log(Level.SEVERE, null, ex);
        }

}
根据:

每个类装入器管理自己的一组本机库相同 JNI本机库不能加载到多个类加载器中。 这样做会导致抛出UnsatifiedLinkError。例如 System.loadLibrary用于加载时抛出未满足的链接错误 本机库分为两个类加载器

在应用程序服务器中,应用程序的每个实例都使用一个新的类加载器,因此如果多个应用程序尝试加载同一个本机库,或者如果在不重新启动整个应用程序服务器的情况下重新启动单个应用程序,则会看到此错误。一些选择:

  • 从服务器范围的类加载器加载本机库,该类加载器可由服务器中的所有应用程序共享,并且在应用程序重新启动时不会重新创建。大多数应用服务器都支持这一点,但配置是特定于产品的
  • 如果只有一个应用程序正在访问本机库,但它正在重新启动,那么请重新启动整个应用程序服务器JVM
  • 如果多个应用程序正在访问本机库,则将本机库复制到不同的位置,以诱使JVM加载它两次

  • 欢迎来到SO,你能把这个错误的代码片段贴在哪里吗?