Product:
Search Type:

Tomcat application gets java.security exception due to some permission error.

Article ID: 919 
Last Review: Nov,30 2006
APPLIES TO:
  • Plesk for Linux/Unix

RESOLUTION


Such problem usually occurs if an application tries to access some resources but it has no rights to access them due to Tomcat security settings which can be managed through $CATALINA_HOME/catalina.policy. The errors can be realated to MySQL dstsbsde connection or some file accessing. Let see typical permission errors.

1. An application cannot connect to MySQL database. The error received: "Unable to connect to any hosts due to exception: java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)"

To allow
DOMAIN.TLD/APPLICATION/ WebApp TCP/IP connections add the section into catalina.policy:
 
grant codeBase "file:/var/cache/tomcat4/work/PSA/DOMAIN.TLD/APPLICATION/-" {
permission java.net.SocketPermission "IP_ADDRESS", "resolve, connect";
};




Restart Tomcat service after catalina.policy modification.

See for more information: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/security-manager-howto.html


Note: for Debian the lines must be added into /etc/tomcat4/policy.d/04webapps.policy.
Note: Tomcat 5 has similar settings, see http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html


Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
*Please type the code you can see.
* - required fields