问题1:
运行起来不报错,不过在Console没有zookeeper的心跳信息,也就是说没有配置上zookeeper,而出错的原因是下面蓝色这段解析不了
spring-dubbo-provider.xml
<?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="dubbo-service" /> <!-- 使用zookeeper注册中心暴露服务地址:部署zookeeper控制台的电脑ip --> <dubbo:registry address="zookeeper://127.0.0.1:2181" /> <!-- 用dubbo协议在20880端口暴露服务 host="192.168.3.53" --> <dubbo:protocol name="dubbo" host="192.168.3.53" port="20883" /> <!-- 声明需要暴露的服务接口,对应的具体实现类是自定义bean --> <dubbo:service interface="com.zk1.service.IUserService" ref="userService" /> <!-- 服务实现 --> <bean id="userService" class="com.zk1.service.impl.UserServiceImpl" /></beans>解决方法:
把 dubbo-2.5.3.jar解压,把解压出来的dubbo.xsd 随便你放一个地方,打开eclipse--》Preferences--》XML--》XML Catalog --》add --》File System 把刚才dubbo.xsd弄进来,再改一下Location下面的Keyhttp://code.alibabatech.com/schema/dubbo 改为 http://code.alibabatech.com/schema/dubbo/dubbo.xsd 然后保存
问题2:
2016-12-19 20:20:21 AbstractConfig:301 WARN - [DUBBO] keefer: keefer: unknown error, dubbo version: 2.5.3, current host: 127.0.0.1
java.net.UnknownHostException: keefer: keefer: unknown error at java.net.InetAddress.getLocalHost(InetAddress.java:1505) at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:299) at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281) at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242) at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143) at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)解决方法:
在 spring-dubbo-provider.xml 文件里边
<dubbo:protocol name="dubbo" port="20883" />改成下面这个,加上host地址(记着,本人用127.0.0.1测试无效)
<dubbo:protocol name="dubbo" host="192.168.3.53" port="20883" />
问题3:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [/home/keefer/JAVA/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zk1service/] instead of [/home/keefer/JAVA/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zk1client/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files! at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:161) at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:119) at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:49) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)解决方法:
将web.xml文件里边的spring监听器
<listener>
<description>spring监听器</description> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>修改成
<listener>
<description>spring监听器</description> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>dubbo消费者这端不用log4j日志配置,去掉就好