67,512
社区成员
发帖
与我相关
我的任务
分享
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': FactoryBean threw exception on object creation; nested exception is java.lang.UnsupportedOperationException
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:177)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1640)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080)
at org.apache.dubbo.demo.init.Consumer.main(Consumer.java:13)
Caused by: java.lang.UnsupportedOperationException
at java.util.concurrent.CopyOnWriteArrayList$COWIterator.set(CopyOnWriteArrayList.java:1185)
at java.util.Collections.sort(Collections.java:170)
at org.apache.dubbo.rpc.cluster.RouterChain.sort(RouterChain.java:87)
at org.apache.dubbo.rpc.cluster.RouterChain.initWithRouters(RouterChain.java:67)
at org.apache.dubbo.rpc.cluster.RouterChain.<init>(RouterChain.java:57)
at org.apache.dubbo.rpc.cluster.RouterChain.buildChain(RouterChain.java:46)
at org.apache.dubbo.registry.integration.RegistryDirectory.buildRouterChain(RegistryDirectory.java:622)
at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:385)
at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:367)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:114)
at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:70)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:65)
at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:366)
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:305)
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:231)
at org.apache.dubbo.config.spring.ReferenceBean.getObject(ReferenceBean.java:71)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:170)
... 6 more
package org.apache.dubbo.demo.init;
import org.apache.dubbo.demo.DemoService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Consumer {
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {
"classpath*:META-INF/spring/spring-config.xml"
});
context.start();
System.out.println("[consumer] 服务已经启动");
DemoService demoService = (DemoService) context.getBean("demoService");
String hello = demoService.sayHello("world");
System.out.println(hello);
System.in.read();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<dubbo:application name="consumer-of-helloworld-app"/>
<!--使用 zookeeper 注册中心暴露服务,这里使用不能用client="zkclient"否则会报错,详细原因见:
https://github.com/apache/incubator-dubbo/issues/4084
-->
<dubbo:registry address="zookeeper://127.0.0.1:2181" client="curator" />
<!-- 用dubbo协议在20880端口暴露服务 -->
<!-- dubbo:protocol name="dubbo" port="20880" /-->
<dubbo:reference id="demoService" interface="org.apache.dubbo.demo.DemoService"/>
</beans>