java.lang.UnsatisfiedLinkError: no GurobiJni / Tomcat

前端 未结 1 1975
Happy的楠姐
Happy的楠姐 2021-01-23 08:39

We are trying to run Gurobi through a Java web application with Tomcat server in a CentOS. System variables are defined:

declare -x GRB_LICENSE_FILE=\"/home/supo         


        
1条回答
  •  自闭症患者
    2021-01-23 09:10

    Any idea to solve the problem?

    You can set LD_LIBRARY_PATH to point to the directory of Gurobi where the .so files are stored, and also the directory where the .jar files are stored.

    You can also make Gurobi jar file accessible from Tomcat by copying or linking it.

    ln -sv $GUROBI_HOME/lib/gurobi.jar $TOMCAT_HOME/lib/
    

    Edit 1

    try

    declare -x LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
    

    instead of

    declare -x LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:\${GUROBI_HOME}/lib"
    

    There is a mistake by using \ , and you didn't copy/paste the official doc.

    For further debugging, create a JSP with this content, it displays all System properties and we'll see java.library.path. It's weird nobody ever posted this before.

    <%@ page import="java.util.Properties" %>
    <%@ page import="java.util.Set" %>
    
    <%
    Properties p = System.getProperties();
    
    Set keys = p.stringPropertyNames();
    for (String key : keys)
      out.println(key + " : " + p.getProperty(key));
    
    %>
    

    Edit 2

    From your debug JSP we see that ld.library.path is correctly pointing to your GUROBI lib directory. We can try adding a System Property for java.library.path. In your Tomcat installation, edit or create bin/setenv.sh file with this content :

    CATALINA_OPTS="-Djava.library.path=/opt/gurobi752/linux64/lib/"
    

    An explanation to this suggestion can be read here.

    btw I don't know where you put your declare -x , but it would be legitimate to store them in bin/setenv.sh

    0 讨论(0)
提交回复
热议问题