cancel
Showing results for 
Search instead for 
Did you mean: 

ServiceTask after usertask ?

stroobat
Champ in-the-making
Champ in-the-making
I have the following configuration:

<?xml version="1.0" encoding="UTF-8"?>

<definitions>
   <process name="Order_model" id="Order_model">

      <startEvent id="startOrder" name=""/>

      <serviceTask id="INITIATE_ORDER" name="Initiate the order" activiti:expression="#{orderServiceImpl.initiateOrder(execution)}" />

      <userTask id="provisionOrder" name="Validate and provision the order" activiti:formKey="approve.form">
          <documentation>
            This form will be used to manually approve the orders.  
          </documentation>
          <potentialOwner>
            <resourceAssignmentExpression>
              <formalExpression>management</formalExpression>
            </resourceAssignmentExpression>
          </potentialOwner>
      </userTask>
      <endEvent id="endOrderEvent" name=""/>
<serviceTask id="PLACE_ORDER" name="Place and persist the order" activiti:expression="#{orderServiceImpl.placeOrder(execution)}" />
      <sequenceFlow id="SequenceFlow" name="" sourceRef="startOrder" targetRef="INITIATE_ORDER"/>
      <sequenceFlow id="SequenceFlow_1" name="" sourceRef="INITIATE_ORDER" targetRef="provisionOrder"/>
      <sequenceFlow id="SequenceFlow_2" name="" sourceRef="provisionOrder" targetRef="PLACE_ORDER"/>
      <sequenceFlow id="SequenceFlow_3" name="" sourceRef="PLACE_ORDER" targetRef="endOrderEvent"/>
   </process>
</definitions>

The first servicetask runs without a problem.
I can open the taskform in the activiti explorer. But when I hit the OK button in the form I get the exception:

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'orderServiceImpl'
   at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
   at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
   at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
   at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
   at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
   at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:44)
   … 36 more

Seems like activiti tries to resolve the xml line:

<serviceTask id="PLACE_ORDER" name="Place and persist the order" activiti:expression="#{orderServiceImpl.placeOrder(execution)}" />
as a field submitted from the form.

The method and class exist. Even when I use the same xml as the first serviceTask I still get the same error.
My intention is just to execute the method placeOrder in the class OrderServiceImpl after I hit the 'OK' button in the activiti form.

Any ideas ?
9 REPLIES 9

stroobat
Champ in-the-making
Champ in-the-making
I changed the flow that when the userforms has finished, the flow should ends and this seems to work.

<sequenceFlow id="SequenceFlow_2" name="" sourceRef="provisionOrder" targetRef="endOrderEvent"/>
So activiti (5.0) seems to have problems by calling a servicetask after a usertask ? Is this a bug ? Or should I configure some other properties ?

Tom.

stroobat
Champ in-the-making
Champ in-the-making
Just forgot to mention that the I try to call Springbeans in the servicetask method. Springbeans are declared through the @Service annotation.

frederikherema1
Star Contributor
Star Contributor
Hi,

Calling a service-task after a user-task works, that's not the problem. Seems like the spring-beans can't be resolved. Can you post your spring-configuration, where you configure the engine in? Looks like the annotated classes aren't picked up by the application-context.

Cheers,
Frederik

stroobat
Champ in-the-making
Champ in-the-making
Thanks for the reply.

Bean resolution works but only if I use them before the <userTask/>

Here is the content of my spring files:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location" value="file:/appl/webservers/apache-tomcat-7.0.6/conf/platform.properties" />
</bean>

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="databaseType" value="oracle" />
  <property name="dataSource" ref="myDataSource" />
  <property name="transactionManager" ref="myTxManager"/>
  <property name="databaseSchemaUpdate" value="false" />
  <property name="jobExecutorActivate" value="${activiti.jobexecutor}" />
        <property name="deploymentResources">
            <list>
                <value>classpath*:be/xxx/poc/*.bpmn20.xml</value>
                <value>classpath*:be/xxx/poc/taskform/*.form</value>
            </list>
        </property>
  <property name="history" value="full" />
</bean>

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
  <property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>

<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
</beans>

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:component-scan base-package="be.scarlet.poc.bpm" />
    <context:component-scan base-package="be.scarlet.poc.controller" />
   

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

</beans>


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsSmiley Surprisedxm="http://www.springframework.org/schema/oxm"
       xmlns:sws="http://www.springframework.org/schema/web-services"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-1.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
    http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <!– Scans the classpath of this application for @Components to deploy as beans –>
    <context:component-scan base-package="be.xxx.poc.controller"/>

    <!– Configures the @Controller programming model –>
    <mvc:annotation-driven/>
</beans>

frederikherema1
Star Contributor
Star Contributor
Is it possible to create a simple example process and unit-test (http://activiti.org/userguide/index.html#springUnitTest) that shows the exact problem?

tvanhoec
Champ in-the-making
Champ in-the-making
Hi,

An example was provided in http://jira.codehaus.org/browse/ACT-636.

Via JUnit the test is successful; however when completing a UserTask via the explorer the serviceTaks bean can not be resolved. 

Kind Regards,
Tom

mproch
Champ in-the-making
Champ in-the-making
How do you exactly deploy your solution? How do you expose the REST API used by Explorer? I couldn't figure it out from the archive attached to JIRA…
Is it so, that you have 2 separate webapps - one activiti-rest included in distro, and second one - oss-bss-workflow?

If so, than this will not work. Because than you have 2 engines, sharing one DB. Only one (embedded in oss-bss-workflow) can access orderService. The one used when form is submitted by explorer uses only activiti default spring config, so it cannot access spring config deployed in oss-bss-workflow.

Again, I don't know if this is the case, but I cannot see any other reason - as unit test work, you say. And if this is the case, then one possibility would be to embed activiti-rest webapp in your webapp, so that only one engine is used

frederikherema1
Star Contributor
Star Contributor
Maciek may have a point.

If you are using the explorer, the process-engine is obtained through ProcessEngines.getProcessEngine(…). The configuration (activiti.cfg.xml) is only used to fetch the ProcessEngine bean itself.

Are your spring-services you want to use, declared in the same XML file as the ProcessEngineFactoryBean?

nocheinandi
Champ in-the-making
Champ in-the-making
Hallo everyone,

I am struggling with the same problem, see http://forums.activiti.org/en/viewtopic.php?f=6&t=4175

Is there any solution?

Best regards,

Andi