多个service注册到zookeeper,发生冲突。有没有哪位大神遇到过这种错误啊 5C

注册服务到zookeeper能成功,接着注册另一个也成功,只是,前一个服务就报错了,两个服务注册的先后顺序调换,也出现一样的问题。
就好像二者发生了冲突,但他们的端口号是不同的。
com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://192.168.25.1:20885/cn.e3mall.content.service.ContentCategoryService?anyhost=true&application=e3-content-service&channel.readonly.sent=true&codec=dubbo&dubbo=2.5.3&heartbeat=60000&interface=cn.e3mall.content.service.ContentCategoryService&methods=getContentCategoryList&pid=11044&revision=0.0.1-SNAPSHOT&side=provider&timestamp=1519640033133) Failed to bind NettyServer on /192.168.25.1:20885, cause: Failed to bind to: /0.0.0.0:20885
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:289)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.openServer(DubboProtocol.java:266)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.export(DubboProtocol.java:253)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:55)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:56)
at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:153)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:107)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)
at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)
at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)
at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)
at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)
at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)
at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3800)
at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1411)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1384)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1620)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1164)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1388)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1392)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1360)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to bind NettyServer on /192.168.25.1:20885, cause: Failed to bind to: /0.0.0.0:20885
at com.alibaba.dubbo.remoting.transport.AbstractServer.(AbstractServer.java:72)
at com.alibaba.dubbo.remoting.transport.netty.NettyServer.(NettyServer.java:63)
at com.alibaba.dubbo.remoting.transport.netty.NettyTransporter.bind(NettyTransporter.java:33)
at com.alibaba.dubbo.remoting.Transporter$Adpative.bind(Transporter$Adpative.java)
at com.alibaba.dubbo.remoting.Transporters.bind(Transporters.java:48)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchanger.bind(HeaderExchanger.java:41)
at com.alibaba.dubbo.remoting.exchange.Exchangers.bind(Exchangers.java:63)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:287)
... 38 more
Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:20885
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)
at com.alibaba.dubbo.remoting.transport.netty.NettyServer.doOpen(NettyServer.java:94)
26-Feb-2018 18:13:53.433 严重 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
at com.alibaba.dubbo.remoting.transport.AbstractServer.(AbstractServer.java:67)
26-Feb-2018 18:13:53.434 严重 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
... 45 more
Caused by: java.net.BindException: Address already in use: bind
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.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:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 more

2个回答

端口重复占用,两个服务都是20885端口,就会存在这个问题,将其中的一个服务换一个和其他服务不冲突的端口号就行了

weixin_39343976
恭~ 找到答案了,看第二条评论
2 年多之前 回复
weixin_39198774
weixin_39198774 回复weixin_39343976: 肯定是有一个默认的端口配置的问题,后面的注册服务默认采用和前面相同的端口,但是因为不知道你这是代码报错还是配置什么的,没办法指出来
2 年多之前 回复
weixin_39198774
weixin_39198774 回复weixin_39343976: 你沿着端口这条线来解决
2 年多之前 回复
weixin_39343976
恭~ 而且注册的先后顺序反过来,报的也是这个错,只是端口是另外一个端口了
2 年多之前 回复
weixin_39343976
恭~ 端口没有重复 一个是20885 另一个是20882 只是20885的注册成功后,再注册20882,20885的那个就报错了,好像就断开了连接,从报错信息看是因为端口被占用了。但明明是两个不同的端口啊
2 年多之前 回复

找到问题的原因了。是因为多个服务部署在同一台tomcat服务器上导致的。具体可能是因为同一tomcat服务器上的项目被重复启动,于是发生端口被占用的情形。
解决问题的办法是,将不同的服务部署到不同的服务器上。这样就能解决问题了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问