会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132462个问题
JAVA 全系列/第一阶段:JAVA 快速入门/JAVA入门和背景知识 34427楼
Python 全系列/第五阶段:数据库编程/mysql的使用 34428楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 34429楼

老师您好,我这里一直提示方法调用失败导致超时

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method addUser in the service com.wqc.dubbo.service.AddUserDubboService. Tried 3 times of the providers [192.168.18.1:20880] (1/1) from the registry 192.168.0.108:2181 on the consumer 192.168.18.1 using the dubbo version 2.5.4. Last error is: Invoke remote method timeout. method: addUser, provider: dubbo://192.168.18.1:20880/com.wqc.dubbo.service.AddUserDubboService?anyhost=true&application=myconsumer&check=false&dubbo=2.5.4&generic=false&interface=com.wqc.dubbo.service.AddUserDubboService&methods=addUser&pid=12528&revision=0.0.1-SNAPSHOT&side=consumer&timeout=10000&timestamp=1581422713401, cause: Waiting server-side response timeout by scan timer. start time: 2020-02-11 20:23:59.863, end time: 2020-02-11 20:24:09.864, client elapsed: 1 ms, server elapsed: 10000 ms, timeout: 10000 ms, request: Request [id=11, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=addUser, parameterTypes=[class com.wqc.pojo.Users], arguments=[com.wqc.pojo.Users@13e1dc08], attachments={path=com.wqc.dubbo.service.AddUserDubboService, interface=com.wqc.dubbo.service.AddUserDubboService, version=0.0.0, timeout=10000}]], channel: /192.168.18.1:59122 -> /192.168.18.1:20880
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method addUser in the service com.wqc.dubbo.service.AddUserDubboService. Tried 3 times of the providers [192.168.18.1:20880] (1/1) from the registry 192.168.0.108:2181 on the consumer 192.168.18.1 using the dubbo version 2.5.4. Last error is: Invoke remote method timeout. method: addUser, provider: dubbo://192.168.18.1:20880/com.wqc.dubbo.service.AddUserDubboService?anyhost=true&application=myconsumer&check=false&dubbo=2.5.4&generic=false&interface=com.wqc.dubbo.service.AddUserDubboService&methods=addUser&pid=12528&revision=0.0.1-SNAPSHOT&side=consumer&timeout=10000&timestamp=1581422713401, cause: Waiting server-side response timeout by scan timer. start time: 2020-02-11 20:23:59.863, end time: 2020-02-11 20:24:09.864, client elapsed: 1 ms, server elapsed: 10000 ms, timeout: 10000 ms, request: Request [id=11, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=addUser, parameterTypes=[class com.wqc.pojo.Users], arguments=[com.wqc.pojo.Users@13e1dc08], attachments={path=com.wqc.dubbo.service.AddUserDubboService, interface=com.wqc.dubbo.service.AddUserDubboService, version=0.0.0, timeout=10000}]], channel: /192.168.18.1:59122 -> /192.168.18.1:20880
	com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:108)
	com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:229)
	com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)
	com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
	com.alibaba.dubbo.common.bytecode.proxy0.addUser(proxy0.java)

上面是网页反馈的部分提示信息

相关配置反复检查应该没有问题,dubbo-admin查看服务也已经注册了,timeout我也设置了没有用,网上查pojo需要序列化也做了,没有变化。我看到我的dubbo的暴露地址和zookeeper的地址不一样,一个是本地的ipv4,一个是虚拟机的地址,不知道是不是这个问题,拜托老师帮帮忙啦

JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Dubbo 34431楼

"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" "-javaagent:E:\software\idea\ideasoft\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=51820:E:\software\idea\ideasoft\IntelliJ IDEA 2019.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_211\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;C:\IdeaProjects\springbootdemo1\target\classes;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.2.0.RELEASE\spring-boot-starter-web-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter\2.2.0.RELEASE\spring-boot-starter-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot\2.2.0.RELEASE\spring-boot-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.0.RELEASE\spring-boot-autoconfigure-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.2.0.RELEASE\spring-boot-starter-logging-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\wjf\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\wjf\.m2\repository\org\slf4j\slf4j-api\1.7.28\slf4j-api-1.7.28.jar;C:\Users\wjf\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;C:\Users\wjf\.m2\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;C:\Users\wjf\.m2\repository\org\slf4j\jul-to-slf4j\1.7.28\jul-to-slf4j-1.7.28.jar;C:\Users\wjf\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-core\5.2.0.RELEASE\spring-core-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-jcl\5.2.0.RELEASE\spring-jcl-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.2.0.RELEASE\spring-boot-starter-json-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.10.0\jackson-databind-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.0\jackson-annotations-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.10.0\jackson-core-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.0\jackson-datatype-jdk8-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.0\jackson-datatype-jsr310-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.0\jackson-module-parameter-names-2.10.0.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.0.RELEASE\spring-boot-starter-tomcat-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.27\tomcat-embed-core-9.0.27.jar;C:\Users\wjf\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.27\tomcat-embed-el-9.0.27.jar;C:\Users\wjf\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.27\tomcat-embed-websocket-9.0.27.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-validation\2.2.0.RELEASE\spring-boot-starter-validation-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.1\jakarta.validation-api-2.0.1.jar;C:\Users\wjf\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.17.Final\hibernate-validator-6.0.17.Final.jar;C:\Users\wjf\.m2\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\Users\wjf\.m2\repository\com\fasterxml\classmate\1.5.0\classmate-1.5.0.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-web\5.2.0.RELEASE\spring-web-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-beans\5.2.0.RELEASE\spring-beans-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-webmvc\5.2.0.RELEASE\spring-webmvc-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-aop\5.2.0.RELEASE\spring-aop-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-context\5.2.0.RELEASE\spring-context-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-expression\5.2.0.RELEASE\spring-expression-5.2.0.RELEASE.jar" com.wjf.SpringBootHelloWorldApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.0.RELEASE)

2020-02-11 13:17:46.305  INFO 14808 --- [           main] com.wjf.SpringBootHelloWorldApplication  : Starting SpringBootHelloWorldApplication on DESKTOP-GNB6ND7 with PID 14808 (C:\IdeaProjects\springbootdemo1\target\classes started by wjf in C:\IdeaProjects\springbootdemo)
2020-02-11 13:17:46.305  INFO 14808 --- [           main] com.wjf.SpringBootHelloWorldApplication  : No active profile set, falling back to default profiles: default
2020-02-11 13:17:46.495  WARN 14808 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
2020-02-11 13:17:46.639 ERROR 14808 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at com.wjf.SpringBootHelloWorldApplication.main(SpringBootHelloWorldApplication.java:7) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:203) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	... 8 common frames omitted


Process finished with exit code 1

老师,想问一下这是什么问题

JAVA 全系列/(旧的隐藏)第十一阶段:spring全家桶(Spring Boot)/Spring Boot 34433楼

# coding=utf-8

import threading
import time
from queue import Queue

class Pro(threading.Thread):
    def run(self):
        global q
        count = 0
        while True:
            if q.qsize()<1000:
                for i in range(100):
                    count += 1
                    msg = "生产"+str(count)
                    q.put(msg) # 往队列中添加新产品
                    print(msg)
            time.sleep(1)


class Con(threading.Thread):
    def run(self):
        global q
        while True:
            if q.qsize() > 100:
                for i in range(150):
                    msg = self.name+"消费"+q.get()
                    print(msg)
            time.sleep(1)


if __name__ == '__main__':
    q = Queue() # 创建队列,线程中能使用
    for i in range(500): # 放500个初始产品
        q.put("初始产品"+str(i))
    for i in range(2): # 两个生产者
        p = Pro()
        p.start()
    for i in range(5):  # 五个消费者
        c = Con()
        c.start()

老师,我给生产者设置的遍历区间是range(100),给消费者设置的是range(150),为什么消费者不能消耗完队列里面的产品,程序一会在执行。还有就是为什么要放入初始500个产品。

Python 全系列/第三阶段:Python 网络与并发编程/并发编程 34436楼
Python 全系列/第十五阶段:Python 爬虫开发/移动端爬虫开发- 34437楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 34440楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637