线程死锁在弹簧容器上

时间:2018-10-14 21:34:31

标签: spring spring-mvc

问题详细信息

我们的应用程序是运行在tomcat容器上的高线程应用程序。该应用程序是基于弹簧的应用程序。这是一个多线程应用程序。但是,一段时间后,该应用似乎没有响应。我们进行了线程转储,发现所有线程都在等待在堆栈跟踪中创建的spring bean。这是下面的线程转储。

"sam@torcher|9b12f29d42ea" #201 daemon prio=5 os_prio=0 tid=0x000000000e032800 nid=0x7a7f waiting for monitor entry [0x00002af2ddae9000]
   java.lang.Thread.State: BLOCKED (on object monitor)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:187)
        - waiting to lock <0x0000000700ff0a30> (a java.util.concurrent.ConcurrentHashMap)
         at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:487)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:436)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:412)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:398)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:337)
       at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$LookupOverrideMethodInterceptor.intercept(CglibSubclassingInstantiationStrategy.java:235)
       at com.sam.torch.config.AppConfig$$EnhancerBySpringCGLIB$$fcd39318.getSamTorcherParser(<generated>)
       at com.sam.torch.AppSubscriber.onMessage(AppSubscriber.java:135)

"sam@torcher|9f3c52f5c041" #200 daemon prio=5 os_prio=0 tid=0x000000000eb58800 nid=0x7a7e waiting for monitor entry [0x00002af2dd9e8000]
  java.lang.Thread.State: BLOCKED (on object monitor)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:187)
        - waiting to lock <0x0000000700ff0a30> (a java.util.concurrent.ConcurrentHashMap)
       at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:487)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:436)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:412)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:398)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:337)
       at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$LookupOverrideMethodInterceptor.intercept(CglibSubclassingInstantiationStrategy.java:235)
       at com.sam.torch.config.AppConfig$$EnhancerBySpringCGLIB$$fcd39318.getSamTorcherParser(<generated>)
       at com.sam.torch.AppSubscriber.onMesssage(AppSubscriber.java:135)

代码结构和代码功能概述

我从JMS服务器收到一条消息,我需要找到正确的bean实例来解析消息的内容。

这是我的代码结构

@Configuration         
public class AppConfiguration {


    @Lookup
    public SamTorcher getSamTorcherParser() {
        return null;
    }       
   }

    @Component
    @Scope("prototype")
    public class SamTorcher {
    }

在这里,我得到了SamTorcher类,该类由@Component批注和@Scope("prototype")定义。在这里,我有一个@Configuration注释的AppConfiguration类,旨在引导所有必需的配置。

当我收到消息时,基于messageType,我使用SamTorcher方法查找config.getSamTorcherBean() bean。

以下是spring.io网站上与上述问题相关的JIRA(https://jira.spring.io/browse/SPR-7949),我目前正面临同一问题。 但是,我尚未找到解决此问题的正确方法。

对此表示感谢。

0 个答案:

没有答案