Reprinted from: http://wangchongan.com/articles/java-net-socket-exception-permission-denied.html
Today, under Linux, use Jetty to launch an application to report that the permissions are not exceptional enough. In fact, the reason is very simple, but if the negligence may habitually Google one, I have Google, but found that the online content on the issue is very small. So I have a special record, I hope to be able to meet the same problem of students can help.
The exception content is as follows:
Hsfjettywebappcontext Replace servlet context get file/tmp/hsf_jetty_placeholder/web-inf/common/ Webx-component-and-root.xml
Web Context replacement file to "/tmp/hsf_jetty_placeholder/web-inf/common/webx-component.xml"
2012-09-13 20:37:17.930:info:/:webxcomponents:initialization Completed
2012-09-13 20:37:17.975:info:/:initializing FILTER:MDC
2012-09-13 20:37:17.976:info:/:setloggingcontextfilter–mdc:initialization Completed
2012-09-13 20:37:17.976:info:/:initializing FILTER:WEBX
2012-09-13 20:37:17.980:info:/:webxframeworkfilter–webx:initialization Completed
2012-09-13 20:37:18.077:warn::failed [email protected]:80:java.net.socketexception: Insufficient authority
2012-09-13 20:37:18.078:info::started [Email protected]:8009
2012-09-13 20:37:18.079:INFO::AJP13 is not a secure protocol. Please protect Port 8009
2012-09-13 20:37:18.079:warn::failed [email protected]: java.net.SocketException: Insufficient permissions
Java.net.SocketException: Insufficient Authority
At Sun.nio.ch.Net.bind (Native Method)
At Sun.nio.ch.ServerSocketChannelImpl.bind (serversocketchannelimpl.java:126)
At Sun.nio.ch.ServerSocketAdaptor.bind (serversocketadaptor.java:59)
At Org.mortbay.jetty.nio.SelectChannelConnector.open (selectchannelconnector.java:216)
At Org.mortbay.jetty.nio.SelectChannelConnector.doStart (selectchannelconnector.java:315)
At Org.mortbay.component.AbstractLifeCycle.start (abstractlifecycle.java:50)
At Org.mortbay.jetty.Server.doStart (server.java:235)
At Org.mortbay.component.AbstractLifeCycle.start (abstractlifecycle.java:50)
At Runjettyrun. Bootstrap.main (bootstrap.java:259)
"Recommended Solution"
The reason is because under Linux, if the use of the port below 1024 requires root permissions, so because I am not currently using root permissions, so the permissions are insufficient to use 80 port, it will be reported that the permissions are not abnormal. Change the jetty HTTP port to a port that is not 80 ports and greater than 1024, such as 8080.
Modify the port number in Pom.xml.
"Other Solutions"
If you're going to use port 80 to access your app, is there a way? The answer is yes, we can use the iptables command to resolve.
We can forward the 80 port to 8080 port through the following command, so that the jetty plug-in in eclipse can be bound to the 8080 port,/etc/hosts bound to the daily domain name can also be automatically forwarded via 80 port, so it is convenient.
Tables-t nat-a prerouting-p tcp–dport 80-j redirect–to-ports 8080
Iptables-t nat-a output-p tcp-d 127.0.0.1–dport 80-j redirect–to-ports 8080
can be removed when not needed:
Iptables-t nat-f prerouting
Iptables-t nat-f OUTPUT
The above settings are temporary, if this setting is disabled after reboot, you can refer to this if you want your configuration to be valid after a reboot.
Linux next report java.net.SocketException permissions not enough to solve the abnormal