Using gurobi with grails / tomcat

278 views
Skip to first unread message

Zhanibek Datbayev

unread,
Jan 14, 2015, 4:51:00 PM1/14/15
to gur...@googlegroups.com
Hello gurobi folks!

I'm trying to integrate Gurobi with our internal web application that's built using Grails (JVM-based web framework), gets packaged into war file aand is running on tomcat. So, I'm using Gurobi Java API.
The issue I'm running into is whenever I try to create Gubori object I get an Exception as follows:

java.lang.UnsatisfiedLinkError: no GurobiJni60 in java.library.path
 at java
.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
 at java
.lang.Runtime.loadLibrary0(Runtime.java:849)
 at java
.lang.System.loadLibrary(System.java:1087)
 at gurobi
.GurobiJni.<clinit>(GurobiJni.java:197)
 at gurobi
.GRBEnv.<init>(GRBEnv.java:16)



I understand somehow tomcat fails to find  GurobiJni60 library, but I'm puzzled, because I'm pretty sure the library is there and I specified all the necessary configurations. 

The gurobi is installed on the server and I can successfully run java examples from the command line like so:
cd gurobi600/linux64/examples/build/
make run_java



I've set the gurobi variables in the tomcat7/conf/tomcat7.conf file:
export GUROBI_HOME="/home/ec2-user/gurobi600/linux64/"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
export GRB_LICENSE_FILE="/home/ec2-user/gurobi.lic"



I've also specified java.library.path variable like so:
-Djava.library.path=/home/ec2-user/gurobi600/linux64/lib


Alternatively I tried placing symlinks pointing to the libGurobiJni60.so file into tomcat's lib folder:
tomcat7/lib. I've also tried placing same symlinks into tomcat7/shared/lib and changed tomcat7/conf/catalina.properties to pick up files under share/lib. 
But I'm still getting same error.

I even tried loading libGurobiJni60.so library explicitly like so:
path = "/home/ec2-user/gurobi600/linux64/lib/libGurobiJni60.so"
Runtime.getRuntime().load0(groovy.lang.GroovyClassLoader.class, path)


but it fails with another exception:
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /home/ec2-user/gurobi600/linux64/lib/libGurobiJni60.so
 at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1846)
 at java.lang.Runtime.load0(Runtime.java:795)
 at Script1.run(Script1.groovy:6)


Any pointers or help would be greatly appreciated. 

Warm regards,
  Zhanibek

Ed Rothberg

unread,
Jan 14, 2015, 5:42:56 PM1/14/15
to gur...@googlegroups.com

Is there any chance you are trying to load the 64-bit Gurobi library from 32-bit Java?

Ed


Zhanibek Datbayev

unread,
Jan 14, 2015, 6:28:01 PM1/14/15
to gur...@googlegroups.com
Nope, our java is 64-bit:
[ec2-user@ip-10-146-186-219 ~]$ java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (amzn-2.3.10.3.29.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

I've also tried switching Java to the Sun Java, but still have same error:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

Zhanibek Datbayev

unread,
Jan 15, 2015, 6:51:43 PM1/15/15
to gur...@googlegroups.com
This turned out to be a simple permissions issue. Gurobi was placed in a folder that wasn't accessible by the "tomcat" user.

Brandon Seet

unread,
Apr 1, 2015, 7:54:37 AM4/1/15
to gur...@googlegroups.com
How did you handle this permission problem then?

I think i might be facing the same problem

Zhanibek Datbayev

unread,
Apr 3, 2015, 8:29:40 AM4/3/15
to gur...@googlegroups.com
Tomcat uses its own "tomcat" user to start the web container. 
The parent folder containing gurobi didn't have access permissions and thus executing solver failed. So just make sure every folder on the path leading to gurobi has read and execute permissions (chmod 755 or something like that).



--

---
You received this message because you are subscribed to a topic in the Google Groups "Gurobi Optimization" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gurobi/PPm4bYUJKqk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brandon Seet

unread,
Apr 3, 2015, 12:43:56 PM4/3/15
to gur...@googlegroups.com, itom...@gmail.com
I tried running the make run_java code, which on your end was successful, and it also has the same error

any idea why this is so ?

姚丽丽

unread,
Oct 29, 2015, 2:30:13 AM10/29/15
to Gurobi Optimization
Hi,Zhanibek Datbayev ~ I'm really puzzled because I can't make java_run in /gurobi605/linux64/examples/build/, I set environment variable like this:

export GUROBI_HOME="/usr/local/gurobi605/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${GUROBI_HOME}/lib"
export GRB_LICENCE_FILE="/home/yaolili/gurobi.lic"

And when I typed "make java_run" in command line, I got error message:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no GurobiJni60 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at gurobi.GurobiJni.<clinit>(GurobiJni.java:197)
at gurobi.GRBEnv.<init>(GRBEnv.java:16)
at Mip1.main(Mip1.java:16)
make: *** [Mip1] Error 1 

Do you know how to fix it?


在 2015年1月15日星期四 UTC+8上午5:51:00,Zhanibek Datbayev写道:

Zhanibek Datbayev

unread,
Nov 5, 2015, 4:48:20 AM11/5/15
to gur...@googlegroups.com
Could be a permissions issue. That resolved it for me. I needed to make sure every folder in the path "/home/ec2-user/gurobi600/linux64/lib/" had executable permissions set.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Gurobi Optimization" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gurobi/PPm4bYUJKqk/unsubscribe.
Reply all
Reply to author
Forward
0 new messages