Closed wangjunbo closed 8 years ago
regProtocol应该是zookeeper,不是zk
首先非常感谢你的回复。配置成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=
@wangjunbo 看下是否依赖了motan-registry-zookeeper包?
@qdaxb
`
<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
打包后依赖有问题,可能是少了某些依赖。
@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
嗯,如果是storm之类需要打成一个fat jar的都会有类似问题。除了registry,所有单独jar包形式依赖的spi扩展都需要使用追加模式
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=
这是什么原因?