java mail security Acess Exception in JWS
Hi friends ,
I am using jws2,0 with external jre option
ie.stating jws with httpdnojre -javahome c:\jdk1.3
When I use this option my mailing program throws
exception java.security.AcessControlException .
But,when I used default jre along with jws2.0 then
it works fine .
Can anyone guide me to so that I can use external jre
and run javamail servlet .
Regards
Mahesh
[474 byte] By [
msnangare] at [2007-9-26 8:29:20]

[msnangare],
2 answers for this problem that you are getting:
Q1. You wrote: "When I use this option my mailing program throws exception: java.security.AcessControlException. But,when I used default jre along with jws2.0 then it works fine."
A1. The default JDK for jws2.0 is v1.1.x. It does not have the Security Manager concept hence that is the reason why you can make SMTP/POP3/IMAP connections to your mail servers from your servlet. For JDK 1.2.x and JDK 1.3.x, the Security Manager concepts are there, hence that is why the virtual machine is spilling out the java.security.AcessControlException errors.
To resolve this issue, you will have follow this procedure of giving permission to the VM to make SMTP connections:
(1) Look into the directory c:\<Java Web Server 2.0 home dir>\security
(2) There should be a file named "jserv.policy"
(3) Make a backup copy of this file first, then edit the file.
(4) Add these lines to this file:
grant codeBase "file:${server.root}/tmpdir/-" {
permission java.lang.RuntimePermission "accessClassInPackage.sun.net.www";
permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute";
permission java.util.PropertyPermission "*", "read, write";
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "modifyThread";
permission java.lang.RuntimePermission "modifyThreadGroup";
permission java.lang.RuntimePermission "readFileDescriptor";
permission java.lang.RuntimePermission "writeFileDescriptor";
permission java.lang.RuntimePermission "loadLibrary.*";
permission java.lang.RuntimePermission "queuePrintJob";
permission java.net.SocketPermission "*", "accept, connect, listen, resolve";
};
(5) Save the file and then restart your jws2.0 webserver. The JVM will pick up the new security policy allowing your servlets to make SMTP connections.
Q2. You wrote: "... starting jws with httpdnojre -javahome c:\jdk1.3 ..."
A2. jws2.0 has only been tested with JVMs up to v1.2.x and hence officially supported for JDK v1.2.x if you are using the external JRE option. Most the code will run with JDK 1.3.x but you may find some peculiar behaviour with this latest version of the JDK.
HTH.
Allen Lai
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/
Hi Allen
Thnx for yr reply .
I tried as per given steps, and with jdk 1.2
but I can not avoid security exception .
But I managed to mail servlet through plane socket
programming . ( java.net.Socket class )
but I would be haapy to do it in java mail api.
Is there any thing mail api related security issue ?
Bec. JWS allowing me to handel socket through code .
Regards
Mahesh
[msnangare],
There are some additional notes for JavaMail and jws2.0, see URL:
http://java.sun.com/products/javamail/JavaWebServer.html
It contains information of well documented ways of getting JavaMail and jws2.0 to work succesfully and testing it out with the JavaMailServlet app.
I'm using jws2.0 with JavaMail 1.2 but I did not encounter any security exceptions and am running a few servlets that uses the JavaMail APIs to send e-mails out by connecting to a SMTP server.
HTH.
Allen Lai
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/