在整合dubbo+springboot的項目,項目採用分佈式開發。分別爲springboot-server,springboot-client兩個工程。使用main函數啓動springboot-server,發現正常。打開dubbo-admin查看,發現服務也被註冊進入zookeeper裏面了。html
可是在啓動springboot-client的時候報異常:java
java.lang.IllegalArgumentException: interface org.spring.springboot.dubbo.CityDubboService is not visible from class loader
at com.alibaba.dubbo.common.bytecode.Proxy.getProxy(Proxy.java:98) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.common.bytecode.Proxy.getProxy(Proxy.java:67) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:35) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.proxy.AbstractProxyFactory.getProxy(AbstractProxyFactory.java:49) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.getProxy(StubProxyFactoryWrapper.java:60) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.ProxyFactory$Adpative.getProxy(ProxyFactory$Adpative.java) ~[na:2.5.3]
at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:426) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:300) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:138) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.config.spring.AnnotationBean.refer(AnnotationBean.java:302) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.config.spring.AnnotationBean.postProcessBeforeInitialization(AnnotationBean.java:233) ~[dubbo-2.5.3.jar:2.5.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) [spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) [spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) [spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.spring.springboot.ClientApplication.main(ClientApplication.java:20) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.1.RELEASE.jar:1.5.1.RELEASE]spring
已經很明顯的提示,問題就在spring-boot-devtools-1.5.1.RELEASE.jar這個包裏面,那這個包是哪裏來的呢?原來是爲了開發方便,我在maven裏面引入了熱部署插件:springboot
把這部分代碼屏蔽掉,而後maven clean,從新啓動,而後在client啓動,調用接口的時候又報了一個錯誤:app
Exception in thread "main" com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method findCityByName in the service org.spring.springboot.dubbo.CityDubboService. Tried 3 times of the providers [192.168.0.34:20880] (1/1) from the registry 192.168.2.218:2181 on the consumer 192.168.0.34 using the dubbo version 2.5.3. Last error is: Failed to invoke remote method: findCityByName, provider: dubbo://192.168.0.34:20880/org.spring.springboot.dubbo.CityDubboService?anyhost=true&application=consumer&check=false&dubbo=2.5.3&interface=org.spring.springboot.dubbo.CityDubboService&methods=findCityByName&pid=6516&revision=1.0.0&side=consumer×tamp=1508377074613&version=1.0.0, cause: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76)
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
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:722)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java)
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
... 25 more
Caused by: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
... 28 moremaven
at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:101)
at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227)
at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)
at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
at com.alibaba.dubbo.common.bytecode.proxy0.findCityByName(proxy0.java)
at org.spring.springboot.dubbo.CityDubboConsumerService.printCity(CityDubboConsumerService.java:20)
at org.spring.springboot.ClientApplication.main(ClientApplication.java:22)
Caused by: com.alibaba.dubbo.remoting.RemotingException: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76)
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
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:722)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java)
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
... 25 more
Caused by: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
... 28 more分佈式
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.returnFromResponse(DefaultFuture.java:190)
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:110)
at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96)
at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144)
at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77)
... 6 more
ide
這種錯誤一看就知道應該是Server端報的,也就是說通訊上面是成功了,可是Server端的序列化和反序列化錯誤。這個時候就去看Server端的控制檯,果真發現了一個錯誤:
函數
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82) [dubbo-2.5.3.jar:2.5.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_15]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_15]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_15]
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java) ~[na:2.5.3]
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72) ~[dubbo-2.5.3.jar:2.5.3]
... 25 common frames omitted
Caused by: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
... 28 common frames omittedspring-boot
2017-10-19 09:37:55.998 ERROR 396 --- [:20880-thread-6] c.a.dubbo.rpc.filter.ExceptionFilter : [DUBBO] Got unchecked and undeclared exception which called by 192.168.0.34. service: org.spring.springboot.dubbo.CityDubboService, method: findCityByName, exception: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl, dubbo version: 2.5.3, current host: 127.0.0.1
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82) [dubbo-2.5.3.jar:2.5.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_15]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_15]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_15]
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java) ~[na:2.5.3]
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72) ~[dubbo-2.5.3.jar:2.5.3]
... 25 common frames omitted
Caused by: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
... 28 common frames omitted
2017-10-19 09:37:56.005 ERROR 396 --- [:20880-thread-7] c.a.dubbo.rpc.filter.ExceptionFilter : [DUBBO] Got unchecked and undeclared exception which called by 192.168.0.34. service: org.spring.springboot.dubbo.CityDubboService, method: findCityByName, exception: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl, dubbo version: 2.5.3, current host: 127.0.0.1
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findCityByName to registry://192.168.2.218:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.5.3&export=dubbo%3A%2F%2F192.168.0.34%3A20880%2Forg.spring.springboot.dubbo.CityDubboService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.5.3%26interface%3Dorg.spring.springboot.dubbo.CityDubboService%26methods%3DfindCityByName%26pid%3D396%26revision%3D1.0.0%26side%3Dprovider%26timestamp%3D1508376581314%26version%3D1.0.0&pid=396®istry=zookeeper×tamp=1508376581236, cause: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52) [dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82) [dubbo-2.5.3.jar:2.5.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_15]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_15]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_15]
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
at com.alibaba.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java) ~[na:2.5.3]
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46) ~[dubbo-2.5.3.jar:2.5.3]
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72) ~[dubbo-2.5.3.jar:2.5.3]
... 25 common frames omitted
Caused by: java.lang.ClassCastException: org.spring.springboot.dubbo.impl.CityDubboServiceImpl cannot be cast to org.spring.springboot.dubbo.impl.CityDubboServiceImpl
... 28 common frames omitted
這個問題比較詭異,我也是百思不得其解。由於Caused by: java.lang.ClassCastException這種異常不該該產生纔對,爲啥會產生呢?我想過包衝突,這個是最大的可能性。可是仔細檢查了一下maven發現都是很正常的,也查看了Eclipse的編譯器,都是正常的。這個時候,我嘗試去掉Server裏面的spring-boot-devtools
<!-- 熱部署插件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
再一次啓動,發現竟然成功了。。。
那麼問題來了,爲啥集成spring-boot-devtools會報錯呢?這不該該,不科學,也難以定位。像我就在這個問題上足足浪費了差很少一天的時間。要解決這種問題,又沒啥資料,那就只有一個方法——源代碼走查。
我經過走查springboot-devtools的源碼發現,這玩意兒自帶classLoader,並且仍是兩個。與springboot整合的時候會致使加載順序上出問題,致使程序沒法正常去啓動加載類。可是咱們作開發的時候又不得不使用熱部署,畢竟爲了提升效率減小反覆的部署。這裏提供一個方案,採用Spring提供的springloaded。
如何使用springloaded能夠參考這篇文章: http://www.cnblogs.com/magicalSam/p/7196355.html