tags:

views:

321

answers:

2

In our tomcat application, we catch a CommunicationsException. There are various config parameters which can lead to this, including the database config being set wrong, but also the tomcat config have TOMCAT5_SECURITY=yes

When we catch the exception we want to give a helpful error message to the user. So we want to ask tomcat whether TOMCAT5_SECURITY is set, but we can't work out where in the API this is available.

So what tomcat API call will tell us whether TOMCAT5_SECURITY is enabled?

(The full exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure).

+1  A: 

The only TOMCAT5_SECURITY flag I know of is the one supplied in the Ubuntu package file /etc/default/tomcat5(.5). This is Ubuntu-specific, so I wouldn't expect it to be part of the Tomcat API. Note that the flag sets whether a security manager is used or not, so maybe you should be looking at that.

Glenn
+1  A: 

How about calling some method that must throw a SecurityException when security is enabled? You could cache the result, assuming the setting doesn't change at runtime.

Jörn Zaefferer