Search code examples
linuxeclipsetomcatubuntuport80

Start Tomcat from Eclipse in port 80 ( Linux )


This question has been asked before, but no real answer has been given ( to the best of my knowledge).

Here is the link to the original question: Start Tomcat from Eclipse in port 80 in Ubuntu with Authbind.

  • I do need torun tomcat on port 80.
  • I prefer not having to install tomcat on the computer. I believe it is not required.
  • I want to avoid using port forwarding ( I have to do it now since I find no other solution)

I am using:

  • Ubuntu 12.04
  • Eclipse Juno
  • Tomcat 7
  • OpenJDK 64-Bit Serve - java version "1.7.0_07"

I am able to start tomcat in port 80 as a non root user and without installing tomcat.

I follow this article: http://java.dzone.com/articles/running-tomcat-port-80-user There are a lot of articles about the topic, but I found this article to be simple an complete.

When I try to start tomcat using eclipse it always fails and complains about port 80 been used. But it is not true.In fact, while eclipse is running and while the error is been shown in the screen I am able to manually start tomcat on port 80.

I have noticed that eclipse complains about port 80 been used when it does not have access rights to that port. I did get the same error before I was not able to manually run tomcat on port 80. The difference is that when I manually run tomcat it did log an access right error, and eclipse complains about the usage of the port.

I have modified the eclipse tomcat launcher to include the option "-Djava.net.preferIPv4Stack=true" and to start tomcat as "authbind --deep start"

But I always get the same error.

If I start eclipse as root them it works fine, so I do believe the problem is related to the access rights on port 80 and not to port to been used.

I do assume that eclipse starts tomcat with the same user rights used to start eclipse.

Could anybody provide some support?. I can work by using port forwarding, but I would really like to know what I am missing and how to do it right.


Solution

  • The easiest way is to start tomcat with a listener on port 8080 and forward port 80 to localhost:8080:

    ssh -L 80:localhost:8080 <user>@localhost
    

    Execute this command with sudo