Start Tomcat from Eclipse in port 80 in Ubuntu with Authbind - linux

I have installed Authbind to run Tomcat on port 80 in Ubuntu.
I have followed http://netthink.com/?p=362 to run Tomcat in Ubuntu in port 80.
When I run Tomcat on the command line by typing ./start.sh, Tomcat starts normally on port 80 without any exception.
In order to run Tomcat from Eclipse I installed the Tomcat plugin from http://www.eclipsetotale.com/tomcatPlugin.html. Everything is fine except that when I want to start Tomcat from Eclipse. When I run Tomcat from Eclipse by the Tomcat plugin, I get the following exception:
java.net.BindException: Permission denied :80
And if I add Tomcat as a server in "Server view" in Eclipse and want to start it from Server view I get this exception:
Port 80 required by Tomcat v6.0 Server at localhost is already in use
But I am sure that there is not any process that acquires port 80, because in the same time when I run Tomcat on the command line by typing ./start.sh, Tomcat starts normally on port 80.
How do I run Tomcat from Eclipse on port 80?
Using another port other than 80 and less than 1024 for Tomcat and start it in Server View in Eclipse gave me the same exception. For example, for port 82:
Port 82 required by Tomcat v6.0 Server at localhost is already in use

You said :
But i am sure that there is not any process that acquires port
80,because in the same time when i run Tomcat in command line by
typing ./start.sh ,tomcat starts normally in port 80.
Did you stop Tomcat in command line before starting it with Eclipse ?
To make sure your Tomcat is stopped, type this :
ps -ef|grep tomcat
You should have something like this if Tomcat is stopped :
user 16428 16373 0 13:56 pts/1 00:00:00 grep --color=auto tomcat

try running eclipse as root and then start tomcat (on port 80).. should work. although not an optimal solution. But should work since 80 is a privileged port in linux and requires sudo permissions to run.

You should start eclipse with: authbind --deep eclipse Since eclipse doesn't start tomcat via startup.sh file, inserting authbind there will have no effect.

Related

Boot Spring Application failed on sub user

Whenever I try to run my spring boot application, my Linux machine returns me the following issue:
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-80]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.23.jar!/:8.5.23]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) ~[tomcat-embed-core-8.5.23.jar!/:8.5.23][...](LifecycleBase.java:150) ~[tomcat-embed-core-8.5.23.jar!/:8.5.23]
... 21 common frames omitted
Caused by: java.net.SocketException: Permission denied[...]
The Tomcat connector configured to listen on port 80 failed to start.
The port may already be in use or the connector may be misconfigured.
Hope someone can help me.
I'm guessing you're on Ubuntu. Ports under 1024 can only be opened by root so as a normal unprivileged user you can't run your app on port 80. Why not use another port using server.port property?
As clearly mentioned the port is already in use. Configure spring boot to use some other port.
As said in docs either set server.port as system property using command line option to jvm --server.port=8090 or add application.properties in /src/main/resources/ with
server.port = 8090
For random port use
server.port=0
Run it as root, if Ubuntu or Debian use Sudo your_command. Because ports under 1024 can be used just by root.

Glassfish There is a process already using the admin port 4848

asadmin start-domain domain1
But it shows this error.
There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server.
I have searched and found that it could be the hostname or that the port is used by an other application or server and actually it is used by TCP.
I have no problem with the hostname so I've tried this solution by changing port.
asadmin set server.http-service.http-listener.http-listener-1.port=10080
but it shows this error
remote failure: No configuration found for server.http-service.http-listener.http-listener-1
Command set failed.
I can't understand why.
Assuming you are running glassifhs under linux
1 - Check if glassfish is already runnig.
ps -ef |grep java
kill any process java relative to glassfish
2 - Check if the port 4848 is in use
netstat -nao |grep 4848
3 - Change the default port
Edit the file {glassfish_home}/config/asadminenv.conf
AS_ADMIN_PORT=4848
I just kill all glassfish processes
pkill -f glassfish
I hit the same error.
This was useful - i.e. check you can ping $(hostname). Looks like glassfish checks hostname against IP, possibly during bind process.
My issue was my hostname/ip address in /etc/hosts was not aligned correctly, meaning I could not ping $(hostname). Once aligned and pinged, glassfish started ok.
I just hit this issue today. Be sure to delete the $PATH/TO/domain1/config/pid and $PATH/TO/domain1/config/pid.prev files as well, if the process isn't running but is being reported as still running.

How to uninstall IIS on windows 8.1 so I can XAMPP on port 80

I installed IIS on my Windows 8.1 computer but now I want to work with XAMPP. At first I got this error:
Problem detected!
9:32:40 PM [Apache] Port 80 in use by "Unable to open process" with PID 4!
9:32:40 PM [Apache] Apache WILL NOT start without the configured ports free!
9:32:40 PM [Apache] You need to uninstall/disable/reconfigure the blocking application
9:32:40 PM [Apache] or reconfigure Apache and the Control Panel to listen on a different port
I deleted IIS from control panel and unchecked IIS from "Turn Windows features on and off" then I restarted.
But yet when I type localhost in my browser IIS comes up and doesn't let me use XAMPP as my localhost in my project. When I choose XAMPP for my project and run it then I see error 404 because it can't define XAMPP as my localhost.
I want to work with XAMPP, what should I do?
If you unchecked IIS (and all the child nodes) from the "Windows Features" then IIS is gone, so you might have another process using that port. Historically many applications have decided to use that (chats, music players, and others).
I would run netstat as below to find all the processes that are listening/using TCP port 80 and using the PID find in Task Manager who they are:
netstat -ano | findstr :80
There find the PID (last column) and find the culprit. If it is SYSTEM (usually PID 4, and reading your question, that is likely the case, so keep reading) , then some application is using HTTP.sys to listen in Port 80. So for that you'll need to then look in HTTP.sys, for that:
netsh http show servicestate > out.txt
notepad out.txt
there you can find the registered URLs by searching for ":80/" and see if that gives you a clue of who is doing that.

How to change and start tomcat port in Linux server

I tried to change the server.xml in the Tomcat7 from port=8080 to 8088.
When i start the server using ./startup.sh and then when i hit the URL http://:8088/
i get an error No Route to Host.
JBoss is already running on 8080 , so i want to run tomcat in a different port.

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.
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
I thing to run something which uses the ports 1-1024 under Linux the process has to have the root privileges.
I am not sure if I can be helpful to anyone, but I solved similar problem as described: I started tomcat with startup.sh script, it was working fine on port 80. I restarted machine (just in case) and tried starting the same tomcat from eclipse, but when I got error about port 80 being used.
Turns out eclipse does not take startup scripts from tomcat installation, so it does not use the authbind configuration. The best solution I came up with is to start eclipse with authbind:
authbind --deep ./STS
As to why this didn't work:
I have modified the eclipse tomcat launcher to include the option "-Djava.net.preferIPv4Stack=true" and to start tomcat as "authbind --deep start"
As I understand you tried passing "authbind --deep start" as arguments to tomcat. I believe the point of authbind is to start application authbind with tomcat as argument. I don't see any way to do it in eclipse.
I am also now learning eclipse like u. Even i faced the same problem as you. Then, i changed the port number then server is starting now.
To change the port number, u need to double click the Apache Tomcat at servers. Then click on ports and change the HTTP/1.1 port to any four digit number u wish and save it.
It will work.

Resources