AnsweredAssumed Answered

Error Injecting Beans in Java Service Task

Question asked by rodolfobarbeiro on Nov 4, 2011
Latest reply on Nov 7, 2011 by rodolfobarbeiro
Hello,

The following error is occurring to me when I try to use Bean in Java Service Task.

org.activiti.engine.ActivitiException: Incompatible type set on field declaration 'myService' for class org.myorg.bpmn.tasks.java.JavaService. Declared value has type org.activiti.engine.impl.el.JuelExpression, while expecting org.activiti.engine.delegate.Expression

Injecting my bean in Activiti (file:spring.xml):


<bean id="myService" class="org.myorg.handlers.ServiceHandler" />

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="mailServerHost" value="localhost" />
    <property name="mailServerPort" value="5025" />
    <property name="jobExecutorActivate" value="false" />
    <property name="dbCycleUsed" value="true" />
    <property name="beans">
       <map>
         <entry key="myService" value-ref="myService" />
       </map>
    </property>
  </bean>



My BPMN File:



<serviceTask
   id="CTPService"
   activiti:class="org.myorg.bpmn.tasks.java.JavaService">
   <extensionElements>
      <activiti:field name="myService" expression="#{myService}" />                  
      <activiti:field name="serviceId" expression="CTP.getPlan" />
      <activiti:field name="parameters" expression="event" />             
      <activiti:field name="variablesReturn"  expression="portfolio" />
      <activiti:field name="withoutException" expression="CTPServiceNoException" />
      <activiti:field name="withException" expression="CTPServiceException" />
   </extensionElements>
</serviceTask>


My java class:


package org.myorg.bpmn.tasks.java;

import org.activiti.engine.delegate.Expression;
import org.activiti.engine.impl.pvm.PvmTransition;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;

public class JavaService implements   org.activiti.engine.impl.pvm.delegate.ActivityBehavior {


    private Expression myService;
    private ServiceHandler handler;


    public void execute(ActivityExecution execution) throws Exception {
       …
       handler = (ServiceHandler) myService.getValue(execution);
       …
    }
    …
}

This (<activiti:field name="myService" expression="#{myService}" />) is the correct way to inject my Bean in Java Service Task?

There is another way to do this?

Anyone seen this error?

Thanks,

Rodolfo Barbeiro

Outcomes