[jboss-jira] [JBoss JIRA] Updated: (JBRULES-2727) NullPointerException due to abstract Spring beans in KnowledgeSessionDefinitionParser

Tomasz Nurkiewicz (JIRA) jira-events at lists.jboss.org
Wed Nov 3 09:34:01 EDT 2010


     [ https://jira.jboss.org/browse/JBRULES-2727?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tomasz Nurkiewicz updated JBRULES-2727:
---------------------------------------

    Attachment: JBRULES-2727.patch


The same problem exists in KnowledgeAgentDefinitionParser due to C&P development. See attached patch.

> NullPointerException due to abstract Spring beans in KnowledgeSessionDefinitionParser
> -------------------------------------------------------------------------------------
>
>                 Key: JBRULES-2727
>                 URL: https://jira.jboss.org/browse/JBRULES-2727
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.1.1.FINAL
>         Environment: Ubuntu 10.10, Windows XP, Java 6
>            Reporter: Silvio Wangler
>            Assignee: Mark Proctor
>            Priority: Blocker
>             Fix For: 5.2.0.M1
>
>         Attachments: drools-spring-2727.patch, JBRULES-2727.patch
>
>   Original Estimate: 1 hour
>  Remaining Estimate: 1 hour
>
> 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.
> {code}
> // 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 ) );
>         		}
>         	}       	
>         }      
> {code}
> We use abstract beans in our Spring project and it seems that an abstract bean does not have a _BeanDefinition_
> {code}
> <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>
> {code}
> if you change the equals statement like this no NullPointerException would be thrown
> {code}
> // 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 ) );
>         		}
>         	}       	
>         }      
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list