Java JBoss Fatal error: cannot find the required native library named JLinkNativeLibrary

帅比萌擦擦* 提交于 2021-01-29 02:30:46

问题


I'm trying to work with Wolfram Mathematica Kernel from Java Web Application using JBoss.

Here is a Main Class.

public class Main {

 static KernelLink ml;
 static KernelLink ml2;

 public Main(){
    String path = "-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/9.0/MathKernel.exe'";
    try {

        ml = MathLinkFactory.createKernelLink(path);// подключаем ядро
        ml.setComplexClass(MyComplex.class);

        System.out.println(ml.getComplexClass());
        ml.discardAnswer();
        ml.evaluate("<<hexagon.m");
        ml.discardAnswer();


    }
    catch (Exception e){
        System.out.println(e.toString());
    }
}
}

When I initialize Main Object in Servlet I get an error.

21:30:59,520 ERROR [stderr] (http-/127.0.0.1:8080-2) Fatal error: cannot find the required native library named JLinkNativeLibrary.
21:30:59,520 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/WEbTest_war_exploded].[jsp]] (http-/127.0.0.1:8080-2)  JBWEB000236: Servlet.service() for servlet jsp threw exception:  java.lang.UnsatisfiedLinkError:   com.wolfram.jlink.NativeLink.MLOpenString(Ljava/lang/String;[Ljava/lang/String;)J
at com.wolfram.jlink.NativeLink.MLOpenString(Native Method) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.NativeLink.<init>(NativeLink.java:117) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createMathLink0(MathLinkFactory.java:281) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createMathLink(MathLinkFactory.java:194) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createKernelLink0(MathLinkFactory.java:171) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createKernelLink(MathLinkFactory.java:65) [JLink.jar:4.4.0 January 24 2013]
at kostya.Main.<init>(Main.java:21)

回答1:


The error indicates a problem with loading a native library. Java has a protocol for loading native libraries, which are .DLL files in Windows. Most likely it is starting the application using the explicit path in the string and then failing to load some DLL to communicate with it.

Make sure the directory with DLLs can be seen by Java (try adding it to the system PATH and restarting the server first): https://www.chilkatsoft.com/java-loadLibrary-Windows.asp



来源:https://stackoverflow.com/questions/30005679/java-jboss-fatal-error-cannot-find-the-required-native-library-named-jlinknativ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!