3 Replies Latest reply on Feb 15, 2011 9:21 PM by jose mendoza

    Problem installation jbpm5 with spring beans

    Pavel Sknar Newbie

      Try use bean "drools:kagent" with stataful knowledge session but have exception:

       

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaSingleSessionCommandService': 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

       

      why StatefulKnowledgeSessionBeanFactory of drools-spring do not use knowledge agent?

      KnowledgeSessionDefinitionParser try set this property to factory.

       

      <drools:kagent id="knowledgeAgent" kbase="knowledgeBase" new-instance="false">

           <drools:resources>

                  <drools:resource type="CHANGE_SET" source="classpath:ChangeSet.xml" />

           </drools:resources>

      </drools:kagent>

       

      <drools:kbase id="knowledgeBase">

           <drools:resources>

                  <drools:resource type="BPMN2"

                                   source="classpath:definitions/BPMN2-UserTask.bpmn2" />

           </drools:resources>

           <drools:configuration>

           </drools:configuration>

      </drools:kbase>

       

      <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="knowledgeBase">

           <drools:configuration>

                  <drools:work-item-handlers>

                      <drools:work-item-handler name="Human Task" ref="humanTaskHandler" />

                  </drools:work-item-handlers>

                 <drools:jpa-persistence load="1">

                      <drools:transaction-manager ref="transactionManager" />

                      <drools:entity-manager-factory ref="entityManagerFactory" />

                  </drools:jpa-persistence>

          </drools:configuration>

      </drools:ksession>

        • 1. Problem installation jbpm5 with spring beans
          Mauricio Salatino Master

          Did you try with the latest snapshots? Sounds like an old issue. But it's fixed in the latest version.

          Can provide the Drools and jBPM version that you are using?

          Greetings

          • 2. Problem installation jbpm5 with spring beans
            Pavel Sknar Newbie

            I get latest drools-spring sources from git: last revision number 9f22d34c5db499c51cd69b460143d84a5b0ef3c2 at 03.02.11 19:47.

            Version drools libs is from jbpm binary release (5.2.0.M1).

            • 3. Re: Problem installation jbpm5 with spring beans
              jose mendoza Newbie

              I have the same problem with simple test case using Spring + drools +guvrnor.

              debugging the spring-drools jar,  I found that KnowledgeSessionDefinitionParser is the problem.

              Here the code:

              ....

              ......

                      // find any kagent's for the current kbase and assign

                      for ( String beanName : parserContext.getRegistry().getBeanDefinitionNames() ) {

                          BeanDefinition def = parserContext.getRegistry().getBeanDefinition(beanName);

                          if ( def.getBeanClassName().equals( KnowledgeAgentBeanFactory.class.getName() ) ) {                               

                               PropertyValue pvalue = def.getPropertyValues().getPropertyValue( "kbase" );

                               RuntimeBeanReference tbf = ( RuntimeBeanReference ) pvalue.getValue();                

                              if ( kbase.equals( tbf.getBeanName() ) ) {

                                  factory.addPropertyValue( "knowledgeAgent", new RuntimeBeanReference( beanName ) );

                              }

                          }          

                      }       

               

                      return factory.getBeanDefinition();

                  }

               

               

              it fails when ksession is stateful, because StatefulKnowledgeSessionBeanFactory don't have the property knowledgeAgent

               

              I don't understand the propose of this part of code.

               

              if you change the order definition from xml and define ksession at top, "it works" because how spring container load the beans, and is the reason of in the test cases of drools all works fine.

               

              I tink that is a bug, maybe we need more docs and about spring-drools api.

              Greetings