I want to set the endorsed directory for Tomcat6 so it can use certain libraries instead of the default ones.
So, when I run this in a standalone application:
System.out.println(System.getProperty("java.endorsed.dirs"));
It prints:
/usr/lib/jvm/jdk1.6.0_45/jre/lib/endorsed
However, when I do it an application running in Tomcat, it prints a blank line.
I have tried to modify tomcat6.conf
, with this (and restarting, of course):
JAVA_OPTS=" -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m"
But it still doesn't seem to know that property.
So, how can I tell Tomcat where the endorsed directory is located?
For Tomcat 6 see https://tomcat.apache.org/tomcat-6.0-doc/RUNNING.txt
On Ubuntu the startup script in /etc/init.d/tomcat8 will refer to a config in /etc/default/tomcat8 which has JAVA_OPTS, you can add to it (it uses default env config to build up a complete JAVA_OPTS, so make sure you don't accidentally replace them).
It seems that setting this option in tomcat6.conf:
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
is not enough. It is required to create a variable called JAVA_ENDORSED_DIRS. So these two lines are needed in tomcat6.conf:
JAVA_ENDORSED_DIRS="/usr/share/tomcat6/endorsed"
JAVA_OPTS="-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS [-Djava....]"
Not really well documented issue, I think.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.