top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration "Permission denied": connect, when running Tomcat 7 as a windows service

+2 votes

I'm receiving the following exception: "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.


 - Windows Server 2008 R2 64-bit
 - Tomcat 7.0.39
 - jdk1.6.0_33-x64
posted Oct 23, 2013 by Sumit Pokharna

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

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//-" {
 permission ":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.

answer Oct 23, 2013 by Jagan Mishra
... and even the above is quite distribution-specific. "Vanilla" Tomcat users would find their security configured in CATALINA_BASE/conf/catalina.policy.
Similar Questions
0 votes

I have a JSF2.0 app that executes (via ProcessBuilder) an external script. This script opens PPTX via PowerPoint ActiveX object, manipulate it and save. It runs on Windows Server 2008 R2 64-bit, 4GB RAM, JDK 7.

When tomcat 7 is launched using startup.bat (with original settings), it works fine.

When tomcat runs as a service, opening the PPTX in the PowerPoint fails because of Out Of Memory error regardless Xmx settings (tomcat7w.exe).

I originally asked PowerPoint forum, but haven't get any explanation yet:

But as the entry point is Tomcat and the only difference between problematic and non problematic behavior is the 'service' mode, maybe there is something related in the tomcat7.exe code base. Just guessing.

Has anybody an idea why both modes behave differently?

+1 vote

My development setup is Win7 while my production is RHEL6. Both of the environments have the same settings in conf/ but the files in logs/ are slightly different.

The access logs are named the same way. But on RHEL there's no tomcat7-stdout or tomcat7-stderr log files. Just 'catalina.out.YEAR.MO.DY' and the cumulative "catalina.out" with no date.

What accounts for the differences? Also, how would you stop logging to the 'catalina.out' file. It gets unusably gigantic within a few days.

+1 vote

I am running Tomcat 7.0.41 on a Windows laptop (8.1 Pro). I recently reinstalled the Windows and since re-installing tomcat and my server application, it runs fine when I connect to it from a web browser.

However, when I tell my desktop client app to connect to the server, it fails on the initial connection with a 405status. I am running the server is debug, from Eclipse, and have put breakpoints in the doGet, doPost, and doPut methods of my ControllerServlet class that extends the java.servlet.http.HttpServlet. None of these breakpoints fire before the client gets back the 405 status. (the client works fine if connecting to the real server running tomcat 6 on an Ubuntu server.)

I can find no place locally where verb filtering is being configured.

Any suggestions?

0 votes

I'm trying to install tomcat service for Windows 7 manually on my system through command prompt.

I tried with">>service.bat install MyProject" but it looks like service doesn't get installed properly because I can see the service in the list but when I start it, it throws error.

Any idea on what could be the issue?

I'm not using tomcat's installer for windows as I would like to bundle it along with my project installer with bundled Java as well. I could use other Windows batch scripts of starting and shutting down tomcat which work well.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.