Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2727

NullPointerException due to abstract Spring beans in KnowledgeSessionDefinitionParser

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 5.2.0.M1
    • 5.1.1.FINAL
    • None
    • Hide

      see description

      Show
      see description
    • Low

      This bug is located in the drools-spring component in class org.drools.container.spring.namespace.KnowledgeSessionDefinitionParser.java

      The class compares each Spring bean with a non NullPointer safe equals call.

      // find any kagent's for the current kbase and assign
              for ( String beanName : parserContext.getRegistry().getBeanDefinitionNames() ) {
              	BeanDefinition def = parserContext.getRegistry().getBeanDefinition(beanName); // is null if the Spring bean is abstract
              	if ( def.getBeanClassName().equals( KnowledgeAgentBeanFactory.class.getName() ) ) {        	// NullPointerException comes here due to the abstract bean that does not have a bean definition	        		
              		 PropertyValue pvalue = def.getPropertyValues().getPropertyValue( "kbase" );
              		 RuntimeBeanReference tbf = ( RuntimeBeanReference ) pvalue.getValue();        		 
              		if ( kbase.equals( tbf.getBeanName() ) ) {
              			factory.addPropertyValue( "knowledgeAgent", new RuntimeBeanReference( beanName ) );
              		}
              	}       	
              }      
      

      We use abstract beans in our Spring project and it seems that an abstract bean does not have a BeanDefinition

      <bean id="i18NServiceConfig" abstract="true">
      	<property name="xxx">
      		<ref local="yyy" />
      	</property>
      </bean>
      
      <bean class="de.corag.bpm.cone.service.i18n.I18NServiceImpl" parent="i18NServiceConfig">
                  <property name="messageDao"><ref bean="messageDao"/></property>
      </bean>
      

      if you change the equals statement like this no NullPointerException would be thrown

      // find any kagent's for the current kbase and assign
              for ( String beanName : parserContext.getRegistry().getBeanDefinitionNames() ) {
              	BeanDefinition def = parserContext.getRegistry().getBeanDefinition(beanName);
              	if ( KnowledgeAgentBeanFactory.class.getName().equals( def.getBeanClassName() ) ) {        	// NullPointerException is avoided in this statement        		
              		 PropertyValue pvalue = def.getPropertyValues().getPropertyValue( "kbase" );
              		 RuntimeBeanReference tbf = ( RuntimeBeanReference ) pvalue.getValue();        		 
              		if ( kbase.equals( tbf.getBeanName() ) ) {
              			factory.addPropertyValue( "knowledgeAgent", new RuntimeBeanReference( beanName ) );
              		}
              	}       	
              }      
      

        1. drools-spring-2727.patch
          1 kB
          Silvio Wangler
        2. JBRULES-2727.patch
          1 kB
          Tomasz Nurkiewicz

              kverlaen@redhat.com Kris Verlaenen
              silvio303 Silvio Wangler (Inactive)
              Archiver:
              rhn-support-ceverson Clark Everson

                Created:
                Updated:
                Resolved:
                Archived:

                  Estimated:
                  Original Estimate - 1 hour
                  1h
                  Remaining:
                  Remaining Estimate - 1 hour
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified