jdon导致cpu 99%最后tomcat死掉---banq给予回复

解道jdon 2021-05-04 14:47:13
Tomcat CPU 最后 导致 jdon


问题:最近发现客户的机器tomcat进程的cpu经常在99%基本上导致应用死掉

分析:通过分析,发现很多线程停留,查看堆栈信息如下:

http-80-1 RUNNABLE java.lang.Thread

java.util.HashMap.get(Unknown Source)

com.jdon.container.pico.JdonPicoContainer.getInstance(JdonPicoContainer.java:327)

com.jdon.container.pico.JdonPicoContainer.getComponentInstance(JdonPicoContainer.java:309)

org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:77)

org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:117)

org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:193)

org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:148)

org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:56)

org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:184)

com.jdon.container.pico.PicoContainerWrapper.getComponentNewInstance(PicoContainerWrapper.java:197)

com.jdon.bussinessproxy.target.POJOObjectFactory.create(POJOObjectFactory.java:45)

com.jdon.bussinessproxy.target.DefaultTargetServiceFactory.create(DefaultTargetServiceFactory.java:59)

com.jdon.aop.reflection.MethodInvokerUtil.createTargetObject(MethodInvokerUtil.java:102)

com.jdon.aop.reflection.ProxyMethodInvocation.methodInvoke(ProxyMethodInvocation.java:97)

com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:76)

com.jdon.aop.interceptor.SessionContextInterceptor.invoke(SessionContextInterceptor.java:76)

com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:84)

com.jdon.aop.interceptor.StatefulInterceptor.invoke(StatefulInterceptor.java:82)

com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:84)

com.jdon.aop.interceptor.PoolInterceptor.invoke(PoolInterceptor.java:91)

com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:84)

com.jdon.aop.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:69)

com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:84)

com.jdon.aop.AopClient.invoke(AopClient.java:95)

com.jdon.bussinessproxy.dyncproxy.DynamicProxyWeaving.invoke(DynamicProxyWeaving.java:62)

$Proxy11.getKh_khddById(Unknown Source)

cn.vetech.framework.pszx.model.Kh_khdd_jcqp_tosave_action.checkB2BFKF(Kh_khdd_jcqp_tosave_action.java:943)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

java.lang.reflect.Method.invoke(Unknown Source)

org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)

org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)

org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)

org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)

org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)

javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

cn.vetech.framework.asms.AgentFilter.doFilter(AgentFilter.java:54)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

com.jdon.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:92)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:615)

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)

org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)

org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)

java.lang.Thread.run(Unknown Source)

这个线程基本上卡住,然后越来越多,线程是卡住在java.util.HashMap.get(Unknown Source)

,然后我查看com.jdon.container.pico.JdonPicoContainer.getInstance(JdonPicoContainer.java:327)

这个源码发现里面有一个专门缓存pojo这个配置的实例对象的一个hashmap,代码如下:

public Object getInstance(ComponentAdapter componentAdapter)

{

Object componentKey = componentAdapter.getComponentKey();

Object instance = this.componentKeyToInstanceCache.get(componentKey);

if ((instance == null) &&

(componentAdapter != null)) {

instance = getTrueInstance(componentAdapter);

if (instance != null) {

this.componentKeyToInstanceCache.put(componentKey, instance);

}

}

return instance;

}

这个代码其中 Object instance = this.componentKeyToInstanceCache.get(componentKey);的定义是:

public class JdonPicoContainer

implements MutablePicoContainer, Serializable

{

public static final String module = JdonPicoContainer.class.getName();

private Map componentKeyToAdapterCache = new HashMap();

private Map componentKeyToInstanceCache = new HashMap();

..............

componentKeyToInstanceCache 这个里面存放我定义的service和dao,jdon框架在我获取一个service或者dao的时候判断在这个componentKeyToInstanceCache里面有没有实例,如果没有就实例化一个对象并缓存到这个map中,下次我再次使用这个对象的时候直接从缓存里面取,那么问题是这个componentKeyToInstanceCache不是一个线程同步的对象,因为JdonPicoContainer是一个单例。componentKeyToInstanceCache这个对象相当于是一个全局的。因此如果多线程并发的应用下,这个地方肯定会出现问题。而我为了找这个问题已经都快疯了。然后我下载最新的jdon的框架发现,这个类已经被修改成 private Map componentKeyToInstanceCache = new ConcurrentHashMap(),既然做了调整为什么在网站上没有说明并告知。导致我们使用者带来巨大的麻烦。

本人可能分析有误见谅,希望作者给与回复

[该贴被mianwo602于2012-06-01 13:47修改过]

版权声明
本文为[解道jdon]所创,转载请带上原文链接,感谢
https://www.jdon.com/43971

  1. ASP调用SDK微信分享好友、朋友圈
  2. ASP calls SDK wechat to share friends and circle of friends
  3. SpringCloud(六)Bus消息总线
  4. 详解JavaScript中的正则表达式
  5. Springcloud (6) bus message bus
  6. Explain regular expressions in JavaScript
  7. Java 响应式关系数据库连接了解一下
  8. Java14它真的来了, 真是尾气都吃不到了
  9. 视频:使用Docker搭建RabbitMQ环境
  10. Java responsive relational database connection
  11. Java14 it's really coming. I can't eat the exhaust
  12. Video: building rabbitmq environment with docker
  13. SpringCloud(六)Bus消息总线
  14. 详解JavaScript中的正则表达式
  15. Springcloud (6) bus message bus
  16. Explain regular expressions in JavaScript
  17. Docker实战:用docker-compose搭建Laravel开发环境
  18. Docker: building laravel development environment with docker compose
  19. 求助,JAVA如何获取系统当前所有进程
  20. 有人用过JMeter或用HttpUnit写过测试吗????
  21. Help, Java how to get all the current processes of the system
  22. Has anyone ever used JMeter or written tests in httpUnit????
  23. Living in a mountain village in late spring
  24. Partridge day, spring of HKUST
  25. JavaScript异步编程4——Promise错误处理
  26. 海康摄像SDK开发笔记(一):海康威视网络摄像头SDK介绍与模块功能
  27. JavaScript asynchronous programming 4 -- promise error handling
  28. Haikang video SDK development notes (1): introduction and module functions of Hikvision webcam SDK
  29. JOP:用于FPGA的嵌入式实时系统中的Java优化处理器内核
  30. Spring Boot源码:使用MongoDB MongoTemplate公开REST在几分钟内实现CRUD功能
  31. Spring Boot应用程序事件教程 - reflectoring
  32. 带有Resilience4j断路器的Spring云网关 - rome
  33. 经验分享:Apache Kafka的缺点与陷阱 - Emil Koutanov
  34. 通过Spring Boot Webflux实现Reactor Kafka
  35. 从Java 8升级到Java 11应该注意的问题
  36. Jop: Java optimized processor core for FPGA embedded real time system
  37. Spring boot source code: use mongodb mongotemplate to open rest to realize crud function in a few minutes
  38. Spring boot application event tutorial - reflecting
  39. Spring cloud gateway with resilience4j circuit breaker - ROM
  40. Experience sharing: shortcomings and pitfalls of Apache Kafka - Emil koutanov
  41. Realization of reactor Kafka through spring boot Webflux
  42. RPC框架设计----Socket与I/0模型
  43. Problems in upgrading from Java 8 to Java 11
  44. RPC framework design -- socket and I / 0 model
  45. RPC框架设计----I/0模型
  46. RPC framework design: I / 0 model
  47. RPC框架设计----NIO编程缓冲区Buffer
  48. RPC框架设计----NIO编程缓冲区Buffer
  49. RPC framework design -- NiO programming buffer
  50. RPC framework design -- NiO programming buffer
  51. Java多线程基础
  52. Java multithreading Foundation
  53. 码农飞升记-00-Java发展历程
  54. Development history of coder-00-java
  55. 码农飞升记-00-Java发展历程
  56. Development history of coder-00-java
  57. Spring and Autumn Moon
  58. Node.js与Spring Boot比较? - Ryan Gleason
  59. Spring WebFlux的明显陷阱 - ŁukaszKyć
  60. Spring创始人Rod大叔对YAML的真实想法