1. 程式人生 > >Can't assign requested address

Can't assign requested address

Exception in thread “main” java.lang.IllegalStateException: Can’t assign requested address
at com.alibaba.dubbo.registry.multicast.MulticastRegistry.(MulticastRegistry.java:116)
at com.alibaba.dubbo.registry.multicast.MulticastRegistryFactory.createRegistry(MulticastRegistryFactory.java:30)
at com.alibaba.dubbo.registry.support.AbstractRegistryFactory.getRegistry(AbstractRegistryFactory.java:94)
at com.alibaba.dubbo.registry.RegistryFactoryA

dpative.getRegistry(RegistryFactoryAdpative.java)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:190)
at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:109)
at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)
at com.alibaba.dubbo.rpc.ProtocolA
dpative.export(Protocol
Adpative.java)
at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:488)
at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:284)
at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:245)
at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:144)
at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:954)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
at com.alibaba.dubbo.demo.provider.Provider.main(Provider.java:11)
Caused by: java.net.SocketException: Can’t assign requested address
at java.net.PlainDatagramSocketImpl.join(Native Method)
at java.net.AbstractPlainDatagramSocketImpl.join(AbstractPlainDatagramSocketImpl.java:178)
at java.net.MulticastSocket.joinGroup(MulticastSocket.java:323)
at com.alibaba.dubbo.registry.multicast.MulticastRegistry.(MulticastRegistry.java:90)
… 20 more
dubbo官網的demo專案啟動失敗,
解決方案有兩種:
第一種:關掉WiFi,使用網線連線。

第二種:配置JVM引數(配置到使用了wifi的生產者和消費者的機器啟動引數中):
-Djava.net.preferIPv4Stack=true.
以上兩種方法,在啟動dubbo的demo專案時都可用。