4

I am writing a netty server in a servlet. Every time the servlet get initialized by the container, it starts the netty server. But I always get the bind exception saying that "address already in use: bind". The exception I got is like below.

java.net.BindException: Address already in use: bindAddress already in use: bind

at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:101)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:474)
at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:995)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind0(DefaultChannelHandlerContext.java:488)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:474)
at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:468)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:837)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:193)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:321)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:366)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Unknown Source)

So, is there some one can help get out of this problem. Thanks in advance!

4

1 回答 1

2

某些东西已经在同一个端口上运行。使用“netstat -tuplen”或“lsof -i | grep LISTEN”找出它是哪个进程。

于 2013-08-28T19:09:59.920 回答