[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2727) NullPointerException due to abstract Spring beans in KnowledgeSessionDefinitionParser
Michał Minicki (JIRA)
jira-events at lists.jboss.org
Mon Jan 24 03:52:50 EST 2011
[ https://issues.jboss.org/browse/JBRULES-2727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577365#comment-12577365 ]
Michał Minicki commented on JBRULES-2727:
-----------------------------------------
Come on! So simple fix and it hasn't been fixed since October?!
> NullPointerException due to abstract Spring beans in KnowledgeSessionDefinitionParser
> -------------------------------------------------------------------------------------
>
> Key: JBRULES-2727
> URL: https://issues.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
> Labels: spring3
> 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.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list