cancel
Showing results for 
Search instead for 
Did you mean: 

Error Injecting Beans in Java Service Task

rodolfobarbeiro
Champ in-the-making
Champ in-the-making
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
1 REPLY 1

rodolfobarbeiro
Champ in-the-making
Champ in-the-making
I'm alter my class JavaService

Change type of variable "org.activiti.engine.delegate.Expression" (Interface) to "org.activiti.engine.impl.el.JuelExpression" (Implementation) and the error mysteriously continues…


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.impl.el.JuelExpression

org.activiti.engine.impl.el.JuelExpression != org.activiti.engine.impl.el.JuelExpression ????


It struck me that error can be ClassLoader. The ClassLoader of my application and Acitiviti may be different. Can this be?

I use the module "activiti-spring" to inject Activiti in my application, how can be loading in different classloader?


:?