您的位置:首页 > 编程语言 > Java开发

dubbo服务调用产生AbstractMethodError与解决方法

2016-07-16 12:00 429 查看

dubbo服务调用产生AbstractMethodError与解决方法

因为开发新功能,在服务中新增接口,本地测试一切正常。随后将新的dubbo服务包发布到联调环境中,并调用新接口进行测试,但一直报java.lang.AbstractMethodError: XXXX 异常,随后搜索了AbstractMethodError含义及可能的产生原因。

下面是JDK文档对该异常的定义。

Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.


通过定义可知AbstractMethodError错误原因可能是因为接口文件中新增了接口,而对应的实现中却没有这个接口的实现,导致调用时产生AbstractMethodError异常。

这种异常发生在运行时,是由于实现与接口没有同时更新导致。随后在dubbo服务的lib目录下通过反编译工具查看接口实现的class文件,果然没有新增接口实现。于是重新编译项目并替换jar包,最后问题解决。

此外使用JDBC时候也会出现,例如。

It usually means that you are using an old version of an interface implementation which is missing a new interface method. For example java.sql.Connection interface got a new getSchema method in 1.7. If you have 1.6 JDBC driver and call Connection.getSchema you will get AbstractMethodError.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息