cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Rest and Spring Bean Problem

mgb
Champ in-the-making
Champ in-the-making
Hello Avtiviti people,

I have a problem to call a spring bean from an activiti service task.

In my environment I use the activiti-5.6 with the given configuration. I unpack the activiti-5.6.zip file, open a windows command shell in the setup directory and execute the command “ant demo.install”.

After this I change in the tomcat in “webapps\activiti-rest” the configuration to support the spring configuration.
I remove the file “activiti.cfg.jar” in “webapps\activiti-rest\lib”.
Create a file “activiti.cfg.xml” in “webapps\activiti-rest\WEB-INF\classes”

Content of “activiti.cfg.xml” is :

<?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 Tongue="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <property name="driverClass" value="org.h2.Driver" />
    <property name="url" value="jdbc:h2:tcp://localhost/activiti" />
    <property name="username" value="sa" />
    <property name="password" value="" />
  </bean>

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

  <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="jobExecutorActivate" value="false" />
  </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" />

  <bean id="fastBaseBean" class="fastbase.FastBaseBean" />

</beans>

Than I put some missing spring libraries (jar file) from “activiti-5.6\setup\files\dependencies\libs” into “webapps\activiti-rest\WEB-INF\lib”

In the next step I create the spring bean class with the code:

package fastbase;

public class FastBaseBean {
   
   public void print() throws Exception {
      System.out.println("FastBaseBean");
   }

}

Compile this class and put the “FastBaseBean.class” file it into the tomcat under “webapps\activiti-rest\WEB-INF\classes\fastbase”

Now I create a process definition “FastBaseTest.testDelegateExpression.bpmn20.xml”. The process is:

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

<definitions id="definitions"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="FastBase">
 
  <process id="FastBase">
 
    <startEvent id="start" />
    <sequenceFlow id="flow1" sourceRef="start" targetRef="serviceTask" />
   
    <serviceTask id="serviceTask" activiti:expression="#{fastBaseBean.print()}" />
    <sequenceFlow id="flow2" sourceRef="serviceTask" targetRef="end" />
   
    <endEvent id="end" />
   
  </process>

</definitions>

Than I zip this file and rename it to “FastBaseTest.testDelegateExpression.bar”

Now I start the activiti environment with the command “ant demo.start” in the setup directory.

I login as “kermit” into the “activiti-probe” and deploy the “FastBaseTest.testDelegateExpression.bar” file.

In the next step I login as “kermit” into “activiti-explorer”, go to the process view and start the process.

Result is an error message “09060000 Wrapped Exception (with status template): Unknown property used in expression”.

and the exception in the logfile:

FINE: — starting StartProcessInstanceCmd ——————————————————–
06-Oct-2011 14:01:09 org.activiti.engine.impl.persistence.entity.ExecutionEntity initialize
FINE: initializing ProcessInstance[113]
06-Oct-2011 14:01:09 org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute execute
FINE: ProcessInstance[113] executes Activity(start): org.activiti.engine.impl.bpmn.behavior.NoneStartEventActivityBehavior
06-Oct-2011 14:01:09 org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior performOutgoingBehavior
FINE: Leaving activity 'start'
06-Oct-2011 14:01:09 org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake execute
FINE: ProcessInstance[113] takes transition (start)–flow1–>(serviceTask)
06-Oct-2011 14:01:09 org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute execute
FINE: ProcessInstance[113] executes Activity(serviceTask): org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior
06-Oct-2011 14:01:09 org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: Unknown property used in expression
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:48)
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior.execute(ServiceTaskExpressionActivityBehavior.java:39)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:326)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:92)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:49)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:280)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:70)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:30)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:69)
   at org.activiti.rest.api.process.ProcessInstancePost.executeWebScript(ProcessInstancePost.java:58)
   at org.activiti.rest.util.ActivitiWebScript.executeImpl(ActivitiWebScript.java:68)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)
   at org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
   at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:662)
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'fastBaseBean'
   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:46)
   … 74 more
06-Oct-2011 14:01:09 org.activiti.engine.impl.interceptor.LogInterceptor execute
FINE: — StartProcessInstanceCmd finished ——————————————————–

The same process, spring bean and configuration run as test case in the “activiti-5.6\workspace\activiti-spring-examples” without any problem.

What I make wrong?
1 REPLY 1

trademak
Star Contributor
Star Contributor
Hi,

Is there a reason you don't want to go for Activiti 5.7?
Because of the new Activiti Explorer I would recommend to upgrade if you can.

Best regards,