On Wed, Oct 23, 2013 at 1:59 PM, Rodolfo Piedrabuena <[email protected]
> wrote:
> Hi there,
>
> I'm receiving the following exception:
>
> java.net.SocketException: "Permission denied": connect
>
> when instantiating a Socket from a servlet:
>
> final Socket smtpSocket = new Socket(mailTransportHost, mailTransportPort);
>
> This application was running as a service under Windows Server 3003 R2
> 32-bits. After migrating it to Windows Server 2008 R2 64-bit, I cannot
> longer establish connection with the smtp server.
>
> This only happen when running Tomcat as a service.
> Running as a standalone (starting it up using startup.bat) works fine. No
> exception instantiating Socket, emails are sent.
>
> Environment:
>
> - Windows Server 2008 R2 64-bit
> - Tomcat 7.0.39
> - jdk1.6.0_33-x64
>
> Any help would be much appreciated
>
Have you tried starting the JVM with -Dsocket.permit_connect=true ? Or
maybe enable the permission to open sockets in the catalina policy files
towards the smtp server, So maybe adding permission rule that looks
something like this:
grant codeBase "file:${catalina.base}/webapps/<your_app>/-" {
permission java.net.SocketPermission "<smtp_server_ip>:25", "connect";
};
to /etc/tomcat6/policy.d/50local.policy might help. Sorry I only use
linux/unix wouldn't know where exactly the policy files are on
windows.
Igor