Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Security Manager refused file access for Java Mail

I am using javax.mail API(1.2), bundled with the j2ee package, for an automated email generation of user registration,and getting the following exception

access denied (java.io.FilePermission /web/tomcat/work/hosting/www.mySiteName.com/_/loader/META-INF write)

The full stack trace is
java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
java.security.AccessController.checkPermission(AccessController.java:427)
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
java.lang.SecurityManager.checkWrite(SecurityManager.java:962)
java.io.File.mkdir(File.java:1119)
java.io.File.mkdirs(File.java:1148)
org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:1 811)
org.apache.catalina.loader.WebappClassLoader.findResource(WebappClassLoader.java:920)
org.apache.catalina.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:11 38)
java.lang.Class.getResourceAsStream(Class.java:1998)
javax.mail.Session.loadProviders(Session.java:793)
javax.mail.Session.(Session.java:81)
javax.mail.Session.getInstance(Session.java:103)
website.Email.sendThanksToUser(Email.java:37)
blah
blah
blah

My site is designed using jsp
It uses a shared server instance (tomcat 5.0.27)
All other smtp configurations are fine, I 've tested them on my local server.
Some body Pls Help

p.s.
Here is the code snippet

Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gerrys.net");
// Session mailSession = Session.getInstance(props, null);

the remarked line throws an exception that is caught and rethrown as JSPException to the browser
[1781 byte] By [qiqbal] at [2007-11-11 6:49:46]