3 Replies Latest reply on Sep 17, 2009 9:33 AM by jbarrez

    command service

    sravyts

      This might be a very easy question to solve , but I can't find the solution (or maybe I'm completely missing the ball here...)

      I'm trying to create my own custom query (MyQuery which extends AbstractQuery).
      Now is my problem: how can I execute this query?

      I was thinking calling processEngine.execute(query) (since AbstractQuery implements the Command interface), but I can't succeed in getting a processEngine (I'm using spring integration)

      If I autowire processengine I get the following error:

      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.jbpm.api.ProcessEngine] is defined: expected single matching bean but found 2: [jbpmConfiguration, processEngine]
      


      This is my spring configuration:

      <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
       <constructor-arg value="org/mypackage/jbpm.cfg.xml" />
       </bean>
      
       <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
       <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
       <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
       <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
       <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
       <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
      
       <bean id="queryExecutor" class="org.mypackage.QueryExecutor" />
      
      
      


      And QueryExecutor :

      public class QueryExecutor
      {
       @Autowired
       ProcessEngine processEngine
      
       public List query(MyQuery query){
       return processEngine.execute(query);
       }
      }
      



      Is there another way for executing commands using spring integration?
      Or aren't we supposed to execute commands?

      Wkr,
      Sofie





        • 1. Re: command service
          jbarrez

          The SprinfConfiguration class is an implementation of the ProcessEngine, so you shouldn't need to define the processEngine again.

          • 2. Re: command service
            sravyts

            How do you call the buildProcessEngine method if you remove the line

            <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
            

            ?



            • 3. Re: command service
              jbarrez

              @Sofie:

              I'm sorry I hadnt read your code good, so you can neglect my previous command.

              The problem here is that both the Configuration and ProcessEngine (Both interfaces) are mplemented by the SpringConfiguration class. That's why you get the exception.

              I guess the easiest way to quickly fix this issue is to inject by name instead of by type.