[rules-users] spring-drools api exception: Invalid property 'knowledgeAgent'

mmjose26 mmjose26 at yahoo.com.mx
Wed Feb 23 15:29:14 EST 2011


Hi, 
Im runnung test cases in Spring Drools 5.2M1

and I have this exception: 

Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'ksession2': Error setting property values; nested exception is
org.springframework.beans.NotWritablePropertyException: Invalid property
'knowledgeAgent' of bean class
[org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory]:
Bean property 'knowledgeAgent' is not writable or has an invalid setter
method. Does the parameter type of the setter match the return type of the
getter?

it happens with testAgents method 

If you change the source code located in the drools-spring component in
class
org.drools.container.spring.namespace.KnowledgeSessionDefinitionParser.java:



 // 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() ) ) {
                PropertyValue pvalue =
def.getPropertyValues().getPropertyValue( "kbase" );
                RuntimeBeanReference tbf = (RuntimeBeanReference)
pvalue.getValue();
                if ( kbase.equals( tbf.getBeanName() ) ) {
                    factory.addPropertyValue( "knowledgeAgent",
                                              new RuntimeBeanReference(
beanName ) );
                }
            }
        }

modifying:  if ( kbase.equals( tbf.getBeanName() ) &&  "stateless".equals(
sessionType ) ) 
it works, becasue only stateless sessions have knowledgeAgent property.

is It Correct?



-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/spring-drools-api-exception-Invalid-property-knowledgeAgent-tp2562735p2562735.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list