博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java.net.BindException: Address already in use: bind
阅读量:7241 次
发布时间:2019-06-29

本文共 3409 字,大约阅读时间需要 11 分钟。

环境:jxse-2.7, netty-3.6.6.Final  

现象:每次执行都抛出以下异常

八月 08, 2013 8:45:19 下午 net.jxta.logging.Logging logCheckedInfo

INFO: Line 127 net.jxta.impl.endpoint.netty.NettyTransportServer.bindServerChannel()
Attempt to bind to /0.0.0.0:8080 failed (Address already in use: bind), trying another address
八月 08, 2013 8:45:19 下午 org.jboss.netty.channel.SimpleChannelUpstreamHandler
WARNING: EXCEPTION, please implement org.jboss.netty.channel.socket.httptunnel.TunnelWrappedServerChannelHandler.exceptionCaught() for proper handling.
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:366)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:290)
    at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

——————————————————————————————————————————————————————————————————

注意到黄色背景文字,显然8080端口被占用了;才想起最近安装Oracle Database 11g Express Edition,在安装时必须占用8080端口且无法修改。

停止Oracle服务,或按照《http://www.cnblogs.com/cuizhf/p/3246654.html》修改其端口。

上面的异常也说明Jxta绑定了8080端口(Why?),下面是NettyTransportServer初始化时的代码:

private void initServer(TCPAdv instanceConfiguration) throws PeerGroupException {                this.serverEnabled = instanceConfiguration.isServerEnabled();        if(!serverEnabled) {            this.server = new NullTransportServerComponent();            return;        }                String interfaceAddress = instanceConfiguration.getInterfaceAddress();                InetAddress bindAddr;        if(interfaceAddress != null) {            bindAddr = TransportUtils.resolveInterfaceAddress(interfaceAddress);        } else {            bindAddr = IPUtils.ANYADDRESS;        }                String publicName = instanceConfiguration.getServer();        EndpointAddress publicAddress = null;        if (publicName != null) {            publicAddress = new EndpointAddress(protocolName, publicName, null, null);        }                NettyTransportServer server = new NettyTransportServer(createServerSocketChannelFactory(), new InetSocketAddressTranslator(protocolName), group);                int preferredPort = correctPort(instanceConfiguration.getPort(), 1, 65535, getDefaultPort(), getDefaultPort(), "Preferred");        int startPort = correctPort(instanceConfiguration.getStartPort(), 1, preferredPort, getDefaultPortRangeLowerBound(), 1, "Range start");        int endPort = correctPort(instanceConfiguration.getEndPort(), startPort, 65535, getDefaultPortRangeUpperBound(), 65535, "Range end");        List
potentialBindpoints = IPUtils.createRandomSocketAddressList(bindAddr, preferredPort, startPort, endPort); server.init(potentialBindpoints, publicAddress, instanceConfiguration.getPublicAddressOnly()); this.server = server; }

 

 

 

 

 

你可能感兴趣的文章
Spring @PostConstruct和@PreDestroy实例
查看>>
hdu1695 容斥原理 莫比乌斯反演
查看>>
精通移动端布局
查看>>
Hibernate中createCriteria即QBC查询的详细用法
查看>>
《ArcGIS Runtime SDK for Android开发笔记》——(2)、Android Studio基本配置与使用
查看>>
怎么运行 ASP.NET Core控制台程序
查看>>
iOS -Swift 3.0 -UILabel属性大全
查看>>
Convolution1D与Convolution2D区别
查看>>
如何安装Tomcat
查看>>
IOS蓝牙项目总结
查看>>
django一对多 增 删 改 查
查看>>
Sqoop Export原理和详细流程讲解
查看>>
如何实现超高并发的无锁缓存?
查看>>
浅谈对java中锁的理解
查看>>
ASP.NET Core MVC之ViewComponents(视图组件)知多少?
查看>>
在天河二号上对比Julia,Python和R语言
查看>>
Docker容器学习梳理--私有仓库Registry使用
查看>>
arcgis地图服务之 identify 服务
查看>>
取汉子拼音首字母的C#方法
查看>>
C语言 · 求先序遍历
查看>>