Getting Gurobi Environment Object (Java) On Gurobi Cloud

711 views
Skip to first unread message

Brandon Seet

unread,
Mar 31, 2015, 3:09:15 PM3/31/15
to gur...@googlegroups.com
I've implemented my application on AWS Gurobi AMI and have built my tomcat plus my web application on it however, it is throwing me an exception that it is unable to get the Gurobi Environment - Below is the error which have been shown.

On line 1517 - 1518 in my code it is the following [These codes are running on the Gurobi AMI instance]

Line 1517: GRBEnv env = new GRBEnv();
Line 1518: GRBModel model = new GRBModel(env);

---- Error Message ----
Mar 31, 2015 6:38:05 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [RemoteGenerateServlet] in context with path [/ScheduleMyInterview] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoClassDefFoundError: Could not initialize class gurobi.GurobiJni
at gurobi.GRBEnv.<init>(GRBEnv.java:16)
at gurobi.GRBEnv.<init>(GRBEnv.java:11)
at Model.UserInterviewSessionDAO.slotRemoteWeekends(UserInterviewSessionDAO.java:1517)
at Model.UserInterviewSessionDAO.runRemoteLinearProgramming(UserInterviewSessionDAO.java:1084)
at Controller.RemoteGenerateServlet.processRequest(RemoteGenerateServlet.java:43)
at Controller.RemoteGenerateServlet.doGet(RemoteGenerateServlet.java:98)

Brandon Seet

unread,
Mar 31, 2015, 3:34:56 PM3/31/15
to gur...@googlegroups.com
I’ve checked the PATHS,LD_LIBRARY_PATH,GUROBI_HOME, these are all not set am I suppose to set them myself?

Ed Rothberg

unread,
Mar 31, 2015, 10:53:25 PM3/31/15
to gur...@googlegroups.com

You'll need to set the classpath so Java can find the Gurobi jar file (and then you'll need to set LD_LIBRARY_PATH so it can find libGurobiJni60.so and libgurobi60.so).

You should probably get this working from a command-line program, and then make a note of the configuration steps required, before trying to get it running from a web application.

Ed


Brandon Seet

unread,
Apr 1, 2015, 7:54:31 AM4/1/15
to gur...@googlegroups.com
Thanks Ed!

So is it correct to say i'll have to install every path as per the linux installation on the GurobiAMI ?

Brandon

Brandon Seet

unread,
Apr 1, 2015, 7:54:33 AM4/1/15
to gur...@googlegroups.com
Hey Ed!

I've set the paths required as per the linux installation guide and now it churns me a different error.

INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@6ec1884e')
Apr 01, 2015 8:37:08 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [RemoteGenerateServlet] in context with path [/ScheduleMyInterview] threw exception [Servlet execution threw an exception] with root cause
java.lang.UnsatisfiedLinkError: no GurobiJni60 in java.library.path

Any idea why this is so ?

On Wednesday, April 1, 2015 at 10:53:25 AM UTC+8, Ed Rothberg wrote:

Luis F. de Figueiredo

unread,
Jul 27, 2015, 8:43:00 AM7/27/15
to Gurobi Optimization, brandonse...@gmail.com
Hi Brandon,

I have the same error message you describe in your first post. Did you find any solution? 

I find something peculiar about that error message though. The error is triggered by  gurobi.GRBEnv ("...at gurobi.GRBEnv.<init>(GRBEnv.java:16)...") and therefore, I would assume this class is loaded. If that is the case, why  is the class gurobi.GurobiJni not loaded given that it is part of the same jar?

By the way, when running my application I get first this error (error you posted on Apr 1):
java.lang.UnsatisfiedLinkError: no GurobiJni60 in java.library.path
[...]

and after that I always get the first you posted (error you posted in Mar 31):

java.lang.NoClassDefFoundError: Could not initialize class gurobi.GurobiJni
at gurobi.GRBEnv.<init>(GRBEnv.java:16)
[...]

The application tests work fine but the deployment of the application is giving this problems. 

Cheers,
Luis

Luis F. de Figueiredo

unread,
Jul 28, 2015, 7:09:56 AM7/28/15
to Gurobi Optimization, brandonse...@gmail.com, lfdefig...@gmail.com
Okay, got it working. After some fight with Neo4j configurations I finally found a solution. It was simpler than initially thought.

In Neo4j manual, it says that all dependencies need to be packed with the jar:
"Having built your code, the resulting jar file (and any custom dependencies) should be placed in the $NEO4J_SERVER_HOME/plugins directory."

The problem is if you need to link a native library. I couldn't find any note on that in Neo4j's manual, apart from the normal Neo4j JVM configurations.

The solution is very simple, you can add the path for any additional library using the java options that you pass to the Neo4j server.

You can do this by editing the file /etc/neo4j/neo4j-wrapper.conf and add the following line:
wrapper.java.additional=-Djava.library.path=/path/to/native-library

Cheers,
Luis
Reply all
Reply to author
Forward
0 new messages