Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-206

JCAContainer fails to check if beans are abstract before calling beanFactory.getBean()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.1
    • 3.1
    • JCA Container
    • None

    Description

      We have beans defined that are abstract and cannot be instantiated.

      JCAContainer attempts to instantiate all beans with:

      for (int i = 0; i < names.length; i++)

      { // TODO one day we could be smart to only pre-load the correct // types of bean, based on the definitions? String name = names[i]; beanFactory.getBean(name); }

      Result is a BeanIsAbstractException:

      org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'baseXlParser': Bean definition is abstract
      at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:653)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
      at org.codehaus.activemq.jca.JCAContainer.afterPropertiesSet(JCAContainer.java:77)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1065)

      Perhaps something like:

      } else if (!lazyLoad && beanFactory instanceof BeanDefinitionRegistry) {
      BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
      String[] names = registry.getBeanDefinitionNames();
      for (int i = 0; i < names.length; i++)

      { String name = names[i]; BeanDefinition definition = registry.getBeanDefinition(name); if (!definition.isAbstract()) beanFactory.getBean(name); }

      }

      The TO-DO in the code is well stated, what logic can be implemented to selectively get the necesssay beans? The end result is that lazy-init singletons will be instantiated as well, perhaps without cause.

      Also, I believe the code should use BeanFactoryUtils.beanNamesIncludingAncestors(ListableBeanFactory) to account for a potential hierarchy.

      Note I found reference to this exact issue in the Spring Forum (http://forum.springframework.org/viewtopic.php?t=3064) but was unable to find an existing jira issue.

      Thanks,

      Andrew

      Attachments

        Issue Links

          Activity

            People

              jstrachan James Strachan
              awertkin Andrew Wertkin
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: