weibocom / motan

A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.
Other
5.89k stars 1.78k forks source link

在配合zookeeper使用时出现问题 #70

Closed wangjunbo closed 8 years ago

wangjunbo commented 8 years ago

Exception in thread "main" com.weibo.api.motan.exception.MotanFrameworkException: error_message: register error! Could not find extension for registry protocol:zookeeper, make sure registry module for zookeeper is in classpath!, status: 500, error_code: 20008,r= 这是什么原因?

qdaxb commented 8 years ago

regProtocol应该是zookeeper,不是zk

wangjunbo commented 8 years ago

首先非常感谢你的回复。配置成zookeeper不行,所以改成了zk试试,发现也不行。错误如下Exception in thread "main" com.weibo.api.motan.exception.MotanFrameworkException: error_message: register error! Could not find extension for registr y protocol:zookeeper, make sure registry module for zookeeper is in classpath!, status: 500, error_code: 20008,r=

qdaxb commented 8 years ago

@wangjunbo 看下是否依赖了motan-registry-zookeeper包?

wangjunbo commented 8 years ago

@qdaxb `

com.weibo
        <artifactId>motan-registry-zookeeper</artifactId>
        <version>0.1.1</version>
    </dependency>`

有这个依赖。 在eclipse中运行时可以的,但是打成包,直接在命令运行就报这个错误。命令行如下: java -cp m-0.0.1-SNAPSHOT-jar-with-dependencies.jar quickstart.Server

wangjunbo commented 8 years ago

打包后依赖有问题,可能是少了某些依赖。

catslave commented 7 years ago

@rayzhang0603 添加如下配置文件即可。 由于Motan META-INF.services里的RegistryFactory 命名相同,导致在manve编译时Zookeeper的接口配置文件被覆盖,所以在运行时报错,找不到zookeeper协议。

<transformer                                   implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
      <resource>META-INF/services/com.weibo.api.motan.registry.RegistryFactory</resource>
</transformer>

在这里采用配置文件追加的形式编译,配置就会不被覆盖了。 最后编译出来的jar包里的META-INF/services/com.weibo.api.motan.registry.RegistryFactory就不会被覆盖 com.weibo.api.motan.registry.support.LocalRegistryFactory com.weibo.api.motan.registry.support.DirectRegistryFactory com.weibo.api.motan.registry.zookeeper.ZookeeperRegistryFactory

rayzhang0603 commented 7 years ago

嗯,如果是storm之类需要打成一个fat jar的都会有类似问题。除了registry,所有单独jar包形式依赖的spi扩展都需要使用追加模式