I am using Tomcat7 and Ubuntu. I have a Java web application which uses some native libraries. When I run the web application within Eclipse it works through Eclipse internal Tomcat server during debugging. However, when I deploy the applcation to a hosted Tomcat service, the application fails when it reaches the point of loading these libraries.
- I put the native libraries in /home/me/my_shared_libs, and gave
folder and file ownership to user "Tomcat7" --sudo chown
- I give all permissions of the native libraries to "Tomcat7" user
--
sudo chmod
- In do
sudo vi /usr/share/tomcat7/bin/setenv.sh
, and put the following in the fileexport CATALINA_OPTS="-Djava.library.path=/home/me/my_shared_libs"
- Then I restart Tomcat --
sudo service tomcat7 restart
And, whenever refernce to load native libraries is reached, I get an error aboutInvocationTargetException
.
I am also open to the option of adding the native libraries as part of the the application's .WAR file. (Although I am not sure how to do this in Eclipse).
Log of /var/log/tomcat7/catalina.out
-->
Jun 30, 2016 8:11:50 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3643 ms
Load my_native_lib_called. libmachoman.so: cannot open shared object file: No such file or directory
EDIT: I found out something very interesting. Tomcat does pick up the library location that I set above. What happens is I have two types of libraries (.so) files in the location. The first library (libcore.so) calls/loads the the second library (libmachoman.so). libcore.so is found and loaded both libmachoman.so is not, even though both are in the same location.