Jetty启动时发现java.net.SocketException: Permission denied

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013772876/article/details/80318943

Jetty启动时发现java.net.SocketException: Permission denied

2018-05-14 22:53:46.396:WARN::failed Server@52f759d7: java.net.SocketException: Permission denied

java.net.SocketException: Permission denied

at sun.nio.ch.Net.bind0(Native Method)

at sun.nio.ch.Net.bind(Net.java:433)

at sun.nio.ch.Net.bind(Net.java:425)

at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)

at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)

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:275)


默认equinox的jetty是使用 80端口,而在Linux下由于权限的关系,一般程序只能启用1024以上的端口,最简单的办法就是改变Jetty的启动端口让其大于1024,比如8080。

java.net.SocketException: Permission denied报错

09-24

在AndroidManifest.xml文件中添加还是会报错java.net.SocketException: Permission deniedrnrn本人菜鸟一枚,刚刚接触androidrn还请各位大牛帮忙解决一下,感谢!!!rn一下是源码:rnrn[color=#FF0000][b]MainActivity.java[/b][/color]rnpackage com.example.httptest;rnrnimport android.os.StrictMode;rnimport android.util.Log;rnimport android.support.v7.app.AppCompatActivity;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.content.Intent;rnimport android.content.res.AssetManager;rnimport android.os.AsyncTask;rnimport android.support.v7.app.AppCompatActivity;rnimport android.os.Bundle;rnimport android.widget.TextView;rnimport android.widget.Button;rnrnimport java.io.*;rnimport java.io.BufferedInputStream;rnimport java.io.BufferedOutputStream;rnimport java.io.ByteArrayInputStream;rnimport java.io.ByteArrayOutputStream;rnimport java.io.IOException;rnimport java.io.InputStream;rnimport java.io.OutputStream;rnimport java.io.UnsupportedEncodingException;rnimport java.net.HttpURLConnection;rnimport java.net.MalformedURLException;rnimport java.net.URL;rnimport java.util.HashMap;rnimport java.util.Iterator;rnimport java.util.List;rnimport java.util.Map;rnimport java.util.logging.Handler;rnimport java.util.logging.LogRecord;rnrnimport org.json.*;rnrnpublic class MainActivity extends AppCompatActivity rnrn private TextView textview = null;rn public static String text = null;rnrn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn textview = (TextView) findViewById(R.id.textview);rn StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());rn rnrnrnrn public void btnOnClick(View view)rn new MyThread().start();rn textview.setText("text");rn rnrnrnclass MyThread extends Threadrn public void run()rn tryrn URL url = new URL("http://192.168.1.104:80/www/text.php");rn HttpURLConnection conn = (HttpURLConnection) url.openConnection();rn conn.setRequestMethod("POST");rn conn.setDoOutput(true);rn conn.setDoInput(true);rn InputStream is = conn.getInputStream();rn MainActivity.text = readInputStream(is);rn catch (MalformedURLException e)rn e.printStackTrace();rn catch (IOException e)rn e.printStackTrace();rn rnrn rnrn public String readInputStream(InputStream is)rn tryrn ByteArrayOutputStream baos = new ByteArrayOutputStream();rn int length = 0;rn byte[] buffer = new byte[1024];rn while ((length = is.read(buffer))!=-1)rn baos.write(buffer,0,length);rn rn is.close();rn baos.close();rn return baos.toString();rn catch (IOException e)rn e.printStackTrace();rn return "failed";rn rn rnrnrn[color=#FF0000][b]AndroidManifest.xml[/b][/color]rnrnrnrn rn rn rn rnrn rn rn rn rn rn rnrnrnrn[color=#FF0000][b]activity_main.xml[/b][/color]rnrnrnrn rnrn rnrnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭