I want to add gdal library in Tomcat. I read Native libraries not found in Tomcat but don't understand where in startup.bat
I should add -Djava.library.path
.
Errors:
exception
javax.servlet.ServletException: Servlet execution threw an exception
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
root cause
java.lang.UnsatisfiedLinkError: org.gdal.ogr.ogrJNI.GetDriverCount()I
org.gdal.ogr.ogrJNI.GetDriverCount(Native Method)
org.gdal.ogr.ogr.GetDriverCount(ogr.java:98)
org.geotools.data.ogr.OGRDataStore.<clinit>(OGRDataStore.java:169)
test.Read.getKadnum(Read.java:56)
test.Zipper.mifUnzip(Zipper.java:139)
test.Zipper.Unzip(Zipper.java:60)
test.uploadfile.doPost(uploadfile.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.23 logs.
I downloaded gdal 64bit from: http://vbkto.dyndns.org:1280/sdk/PackageList.aspx?file=release-1600-x64-gdal-1-9-mapserver-6-2.zip
It has to be setup in
catalina.bat
instead of startup.bat.can be put after
The accepted answer (as of Feb 2016) is just plain wrong.
You are never supposed to edit
catalina.bat
/catalina.sh
. Don't ! (The only file in Tomcat'sbin/
dir that you are supposed to touch issetenv.bat
).The right config variable is
CATALINA_OPTS
, notJAVA_OPTS
.If you are on Windows then you don't want to quote the value for the SET command as the quotes become part the actual value. (unlike on Unix/Linux)
It is likely you'll want to retain what is already in
java.library.path
.(in the following I'll assume you are on Windows, change accordingly for Linux/Solaris/Mac OSX).
Here's how to do it: Put a file called
setenv.bat
into the same directory ascatalina.bat
. The file will not exist, unless you've created it yourself previously. So create the file. It must have the following content for your purpose:On Windows
java.library.path
will default to%PATH%
so an alternative route to all of the above would have been to change your PATH environment variable.If you do not want to have confusion over exactly from where the JVM will load your native libraries then omit the
%PATH%;
part from the above. Personally I omit%PATH%
for this reason but that is a matter of taste.According to the comments on catalina.bat, I think the right place is CATALINA_OPTS.