[apache/dubbo]奇怪的服务Impl转换错误

2024-05-30 910 views
2

我没有用Spring,裸API Config写的

redis已经搭好可用 jedis 2.0包已经引了

provider端:

package soa.service;

public interface PlayerService {
    String queryById(long id);
}
package soa.service;

public class PlayerServiceImpl implements PlayerService {

    public String queryById(long id) {
        return "FUCK";
    }
}
public class ServiceInitiator {

    private static ServiceConfig<PlayerService> service = new ServiceConfig<PlayerService>(); // 该类很重,封装了与注册中心的连接,请自行缓存,否则可能造成内存和连接泄漏

    public static void listen() {
        PlayerService playerService = new PlayerServiceImpl();
        // 当前应用配置
        ApplicationConfig application = new ApplicationConfig();
        application.setName("center");
        // 连接注册中心配置
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("redis://192.168.1.11:6379");

        // 服务提供者协议配置
        ProtocolConfig protocol = new ProtocolConfig();
        protocol.setName("dubbo");
        protocol.setPort(20880);
//         protocol.setSerialization("json");
        protocol.setThreads(200);

        // 注意:ServiceConfig为重对象,内部封装了与注册中心的连接,以及开启服务端口

        // 服务提供者暴露服务配置

        service.setApplication(application);
        service.setRegistry(registry); // 多个注册中心可以用setRegistries()
        service.setProtocol(protocol); // 多个协议可以用setProtocols()
        service.setInterface(PlayerService.class);
        service.setRef(playerService);
        service.setVersion("1.0.0");

        // 暴露及注册服务
        service.export();
    }
}

ServiceInitiator的listen启动正常,日志也表示连接上了redis,并成功注册。

[2015-12-03 11:32:37,132] INFO  [play-thread-1]  com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:69) -  [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /192.168.1.99:20880, dubbo version: 2.4.9, current host: 127.0.0.1
[2015-12-03 11:32:37,141] INFO  [play-thread-1]  com.alibaba.dubbo.registry.support.AbstractRegistry.loadProperties(AbstractRegistry.java:232) -  [DUBBO] Load registry store file /Users/tr0j4n/.dubbo/dubbo-registry-192.168.1.11.cache, data: {soa.service.PlayerService:1.0.0=empty://0.0.0.0/soa.service.PlayerService?application=yyy&category=providers&connected=true&dubbo=2.4.9&interface=soa.service.PlayerService&methods=queryById&pid=813&revision=1.0.0&side=consumer&timestamp=1449113509365&version=1.0.0}, dubbo version: 2.4.9, current host: 127.0.0.1
[2015-12-03 11:32:37,151] INFO  [play-thread-1]  com.alibaba.dubbo.registry.support.AbstractRegistry.register(AbstractRegistry.java:302) -  [DUBBO] Register: dubbo://192.168.1.99:20880/soa.service.PlayerService?anyhost=true&application=center&dubbo=2.4.9&interface=soa.service.PlayerService&methods=queryById&pid=810&revision=1.0.0&side=provider&threads=200&timestamp=1449113556952&version=1.0.0, dubbo version: 2.4.9, current host: 127.0.0.1
[2015-12-03 11:32:37,165] INFO  [play-thread-1]  com.alibaba.dubbo.registry.support.AbstractRegistry.subscribe(AbstractRegistry.java:325) -  [DUBBO] Subscribe: provider://192.168.1.99:20880/soa.service.PlayerService?anyhost=true&application=center&category=configurators&check=false&dubbo=2.4.9&interface=soa.service.PlayerService&methods=queryById&pid=810&revision=1.0.0&side=provider&threads=200&timestamp=1449113556952&version=1.0.0, dubbo version: 2.4.9, current host: 127.0.0.1

接下来我在本机的另外一个Consumer应用里创建了PlayerService的接口存根,调用方式如文档所述

consumer端:

package soa.service;

public interface PlayerService {
    String queryById(long id);
}
public class ServiceConsumer {
    public static void test(){
     // 当前应用配置
        ApplicationConfig application = new ApplicationConfig();
        application.setName("yyy");

        // 连接注册中心配置
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("redis://192.168.1.11:6379");
//        registry.setUsername("admin");
//        registry.setPassword("123456");

        // 注意:ReferenceConfig为重对象,内部封装了与注册中心的连接,以及与服务提供方的连接

        // 引用远程服务
        ReferenceConfig<PlayerService> reference = new ReferenceConfig<PlayerService>(); // 该类很重,封装了与注册中心的连接以及与提供者的连接,请自行缓存,否则可能造成内存和连接泄漏
        reference.setApplication(application);
        reference.setRegistry(registry); // 多个注册中心可以用setRegistries()
        reference.setInterface(PlayerService.class);
        reference.setVersion("1.0.0");

        // 和本地bean一样使用xxxService
        PlayerService xxxService = reference.get(); // 注意:此代理对象内部封装了所有通讯细节,对象较重,请缓存复用
        String p = xxxService.queryById(25L);
        System.out.print(p.toString());
    }
}

调用时,provider端爆出了这样的错误:

[2015-12-03 11:32:49,276] INFO  [DubboRedisSubscribe]  com.alibaba.dubbo.registry.redis.RedisRegistry$NotifySub.onMessage(RedisRegistry.java:483) -  [DUBBO] redis event: /dubbo/soa.service.PlayerService/consumers = register, dubbo version: 2.4.9, current host: 127.0.0.1
[2015-12-03 11:32:55,103] DEBUG [DubboServerHandler-192.168.1.99:20880-thread-2]  com.alibaba.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:60) -  [DUBBO] Decode decodeable message com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation, dubbo version: 2.4.9, current host: 127.0.0.1
[2015-12-03 11:32:55,106] ERROR [DubboServerHandler-192.168.1.99:20880-thread-2]  com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:118) -  [DUBBO] Got unchecked and undeclared exception which called by 192.168.1.99. service: soa.service.PlayerService, method: queryById, exception: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method queryById to registry://192.168.1.11:6379/com.alibaba.dubbo.registry.RegistryService?application=center&dubbo=2.4.9&export=dubbo%3A%2F%2F192.168.1.99%3A20880%2Fsoa.service.PlayerService%3Fanyhost%3Dtrue%26application%3Dcenter%26dubbo%3D2.4.9%26interface%3Dsoa.service.PlayerService%26methods%3DqueryById%26pid%3D810%26revision%3D1.0.0%26side%3Dprovider%26threads%3D200%26timestamp%3D1449113556952%26version%3D1.0.0&pid=810&registry=redis&timestamp=1449113556942, cause: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl, dubbo version: 2.4.9, current host: 127.0.0.1
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method queryById to registry://192.168.1.11:6379/com.alibaba.dubbo.registry.RegistryService?application=center&dubbo=2.4.9&export=dubbo%3A%2F%2F192.168.1.99%3A20880%2Fsoa.service.PlayerService%3Fanyhost%3Dtrue%26application%3Dcenter%26dubbo%3D2.4.9%26interface%3Dsoa.service.PlayerService%26methods%3DqueryById%26pid%3D810%26revision%3D1.0.0%26side%3Dprovider%26threads%3D200%26timestamp%3D1449113556952%26version%3D1.0.0&pid=810&registry=redis&timestamp=1449113556942, cause: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl
    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.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
    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.TimeoutFilter.invoke(TimeoutFilter.java:42)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
    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.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.dispather.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl
    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: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl
    ... 28 more
[2015-12-03 11:32:55,123] DEBUG [DubboServerHandler-192.168.1.99:20880-thread-3]  com.alibaba.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:60) -  [DUBBO] Decode decodeable message com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation, dubbo version: 2.4.9, current host: 127.0.0.1
[2015-12-03 11:32:55,123] ERROR [DubboServerHandler-192.168.1.99:20880-thread-3]  com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:118) -  [DUBBO] Got unchecked and undeclared exception which called by 192.168.1.99. service: soa.service.PlayerService, method: queryById, exception: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method queryById to registry://192.168.1.11:6379/com.alibaba.dubbo.registry.RegistryService?application=center&dubbo=2.4.9&export=dubbo%3A%2F%2F192.168.1.99%3A20880%2Fsoa.service.PlayerService%3Fanyhost%3Dtrue%26application%3Dcenter%26dubbo%3D2.4.9%26interface%3Dsoa.service.PlayerService%26methods%3DqueryById%26pid%3D810%26revision%3D1.0.0%26side%3Dprovider%26threads%3D200%26timestamp%3D1449113556952%26version%3D1.0.0&pid=810&registry=redis&timestamp=1449113556942, cause: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl, dubbo version: 2.4.9, current host: 127.0.0.1
com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method queryById to registry://192.168.1.11:6379/com.alibaba.dubbo.registry.RegistryService?application=center&dubbo=2.4.9&export=dubbo%3A%2F%2F192.168.1.99%3A20880%2Fsoa.service.PlayerService%3Fanyhost%3Dtrue%26application%3Dcenter%26dubbo%3D2.4.9%26interface%3Dsoa.service.PlayerService%26methods%3DqueryById%26pid%3D810%26revision%3D1.0.0%26side%3Dprovider%26threads%3D200%26timestamp%3D1449113556952%26version%3D1.0.0&pid=810&registry=redis&timestamp=1449113556942, cause: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl

这个转换错误很诡异啊??

Caused by: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl

回答

4

检查下配置文件吧,provider中用dubbo:service/ 定义好接口,ref指向接口的实现类,consumer中用dubbo:reference/,指向接口。贴出你的配置来看看吧

6

我现在换上Spring并使用XML配置的方式了

provider端:

<?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://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans        
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://code.alibabatech.com/schema/dubbo        
            http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <dubbo:application name="center"  />

    <dubbo:registry address="redis://192.168.1.11:6379" />

    <dubbo:protocol name="dubbo" port="20880" />
    <!-- 声明需要暴露的服务接口 --> 

    <dubbo:service interface="soa.service.PlayerService" ref="playerService" />

    <bean id="playerService" class="soa.service.PlayerServiceImpl" />  

</beans>

consumer端:

<?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://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans        
        http://www.springframework.org/schema/beans/spring-beans.xsd        
        http://code.alibabatech.com/schema/dubbo        
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <!-- consumer application name -->
    <dubbo:application name="consumer-of-helloworld-app"  />

    <!-- registry address, used for consumer to discover services -->
    <dubbo:registry address="redis://192.168.1.11:6379" />

    <!-- which service to consume? -->
    <dubbo:reference id="PlayerService" interface="soa.service.PlayerService" />

</beans>

JAVA类没有变。PlayerService和PlayerServiceImpl在Provider端,PlayerService在Consumer端

还是一样的问题,在Consumer端调用后,Provider端会出一个错误。

Caused by: java.lang.ClassCastException: soa.service.PlayerServiceImpl cannot be cast to soa.service.PlayerServiceImpl

错误堆栈和顶楼完全相同

3

建议把所有项目代码上传到自己的git仓库,也好帮你看看是不是代码有问题。

7

有没有自定义类加载之类的?

建议增加jvm参数-verbose:class,把类加载过程打印出来,看看是不是加载了两份存根类。

8

楼主这个问题解决了么

6

我也遇到了相同的错误,求问这个问题怎么解决的?

3

我也遇到了同样问题,但我的环境是在 spring boot 下,报告的异常类似,都是说cast exception,不能把 abc.class cast 为 abc.class。后来添加 jvm 参数 -verbose:class,发现的确是把 abc.class 加载了两次,猜测是因为 spring-boot 开发工具“spring-boot-devtools”导致的,因为这个工具会监控文件更改并自动重新装载类。去掉 spring-boot-devtools 后,问题解决。也许大家的根源不一样,但估计都是“重新装载类”这种功能导致的,供大家参考。

7

我也遇到这个问题了, 是spring-boot-devtools 导致的, 猜测是重新加载类, verbose:class 看到也是加载了一个类, 过程中类也没有修改, 再看看dev 的热布署机制

7

me 2,spring-boot-devtools java.lang.IllegalArgumentException: java.lang.ClassCastException ,有解决办法吗?除了去掉spring-boot-devtools

8

我也遇到这个问题了,` Exception in thread "main" com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method findClearingById in the service c.h.p.clearing.service.ClearingService. Tried 3 times of the providers [169.254.126.234:20881] (1/1) from the registry 127.0.0.1:2181 on the consumer 169.254.126.234 using the dubbo version 2.8.4. Last error is: Failed to invoke remote method: findClearingById, provider: dubbo://169.254.126.234:20881/c.h.p.clearing.service.ClearingService?anyhost=true&application=consumer&check=false&dubbo=2.8.4&generic=false&interface=c.h.p.clearing.service.ClearingService&methods=updateClearingBillName,addClearingBillItem,addClearingBill,completeClearing,findClearingBillPage,findClearingById,findClearingBillItemPage,deleteClearingBillItemById&pid=35568&revision=1.0&side=consumer&timestamp=1485133339215&version=1.0, cause: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findClearingById to registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.8.4&export=dubbo%3A%2F%2F169.254.126.234%3A20881%2Fc.h.p.clearing.service.ClearingService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.8.4%26generic%3Dfalse%26interface%3Dc.h.p.clearing.service.ClearingService%26methods%3DupdateClearingBillName%2CaddClearingBillItem%2CaddClearingBill%2CcompleteClearing%2CfindClearingBillPage%2CfindClearingById%2CfindClearingBillItemPage%2CdeleteClearingBillItemById%26pid%3D37920%26revision%3D1.0%26side%3Dprovider%26timestamp%3D1485133301019%26version%3D1.0&pid=37920&registry=zookeeper&timestamp=1485133300997, cause: java.lang.ClassCastException: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findClearingById to registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.8.4&export=dubbo%3A%2F%2F169.254.126.234%3A20881%2Fc.h.p.clearing.service.ClearingService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.8.4%26generic%3Dfalse%26interface%3Dc.h.p.clearing.service.ClearingService%26methods%3DupdateClearingBillName%2CaddClearingBillItem%2CaddClearingBill%2CcompleteClearing%2CfindClearingBillPage%2CfindClearingById%2CfindClearingBillItemPage%2CdeleteClearingBillItemById%26pid%3D37920%26revision%3D1.0%26side%3Dprovider%26timestamp%3D1485133301019%26version%3D1.0&pid=37920&registry=zookeeper&timestamp=1485133300997, cause: java.lang.ClassCastException: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService 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.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.TimeoutFilter.invoke(TimeoutFilter.java:42) 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:70) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:132) 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:113) 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(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.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: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService ... 28 more

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.findClearingById(proxy0.java)
at c.h.p.springbootdubbo.service.impl.HelloServiceImpl.sayHello(HelloServiceImpl.java:22)
at c.h.p.springbootdubbo.ConsumerApplication.main(ConsumerApplication.java:13)

Caused by: com.alibaba.dubbo.remoting.RemotingException: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findClearingById to registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.8.4&export=dubbo%3A%2F%2F169.254.126.234%3A20881%2Fc.h.p.clearing.service.ClearingService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.8.4%26generic%3Dfalse%26interface%3Dc.h.p.clearing.service.ClearingService%26methods%3DupdateClearingBillName%2CaddClearingBillItem%2CaddClearingBill%2CcompleteClearing%2CfindClearingBillPage%2CfindClearingById%2CfindClearingBillItemPage%2CdeleteClearingBillItemById%26pid%3D37920%26revision%3D1.0%26side%3Dprovider%26timestamp%3D1485133301019%26version%3D1.0&pid=37920&registry=zookeeper&timestamp=1485133300997, cause: java.lang.ClassCastException: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote proxy method findClearingById to registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=provider&dubbo=2.8.4&export=dubbo%3A%2F%2F169.254.126.234%3A20881%2Fc.h.p.clearing.service.ClearingService%3Fanyhost%3Dtrue%26application%3Dprovider%26dubbo%3D2.8.4%26generic%3Dfalse%26interface%3Dc.h.p.clearing.service.ClearingService%26methods%3DupdateClearingBillName%2CaddClearingBillItem%2CaddClearingBill%2CcompleteClearing%2CfindClearingBillPage%2CfindClearingById%2CfindClearingBillItemPage%2CdeleteClearingBillItemById%26pid%3D37920%26revision%3D1.0%26side%3Dprovider%26timestamp%3D1485133301019%26version%3D1.0&pid=37920&registry=zookeeper&timestamp=1485133300997, cause: java.lang.ClassCastException: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService 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.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.TimeoutFilter.invoke(TimeoutFilter.java:42) 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:70) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:132) 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:113) 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(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.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: com.sun.proxy.$Proxy70 cannot be cast to c.h.p.clearing.service.ClearingService ... 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.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.FutureFilter.invoke(FutureFilter.java:53)
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.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
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`

我这也是用springboot启动的,用了teaey的spring-boot-starter-dubbo,也加了spring-boot-devtools。去掉spring-boot-devtools就可以了

2

没有使用spring-boot-devtools也出现了这个问题,怎么破?有遇到类似问题的吗?

7

[2017-08-25 21:30:53.572] [DubboServerHandler-10.28.42.206:20880-thread-47] ERROR rpc.filter.ExceptionFilter - [DUBBO] Got unchecked and undeclared exception which called by 10.28.42.206. service: io.welink.xcourt.foundation.api.CacheService, method: findDeviceValidOrderListBaseInfo, exception: java.lang.AbstractMethodError: io.welink.xcourt.foundation.cache.CacheServiceImpl.findDeviceValidOrderListBaseInfo(Ljava/lang/String;Ljava/util/Map;)[Ljava/lang/Object;, dubbo version: 2.8.4, current host: 127.0.0.1 java.lang.AbstractMethodError: io.welink.xcourt.foundation.cache.CacheServiceImpl.findDeviceValidOrderListBaseInfo(Ljava/lang/String;Ljava/util/Map;)[Ljava/lang/Object; 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) 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:70) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:132) 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:113) 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:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

8

rebuilld一把