The problem I am having is that when I stop the application server (Tomcat) and then restart it, the job for the Start Event timer seems to fire before the process application has finished deploying in Tomcat. This then gives the following error on start up:
org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expressi
on: ${doSomethingDelegate}. Cause: Cannot resolve identifier 'doSomethingDelegat
e'
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression
.java:55)
at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressi
onActivityBehavior.execute(ServiceTaskDelegateExpressionActivityBehavior.java:65
)
After this, the Start Event no longer fires. I have worked around this by having a Spring ApplicationListener<ContextRefreshedEvent> which checks for the failed job an restarts it once the application context has completed loading.
I have also tried specifying the JavaDelegate class explicitly, rather than using an Expression Delegate and that works. However, I want to use the Expression Delegate so that I can have dependency injection by Spring into my JavaDelegate.
Is there another way to achieve a recurring process that uses Spring beans which will survive an application re-start? Is this a bug?
This is using Camunda 7.0.0-Final, deploying to the standard Tomcat 7 distribution that comes with the Camunda download.
I am using the shared engine in Tomcat. I wasn't extending the SpringServletProcessApplication, I was using the ServletProcessApplication. I have fixed that now, so my application class looks like:
@ProcessApplication("Start Timer Test Application")
public class StartTimerApplication extends SpringServletProcessApplication {
}
I have redeployed this, but the same problem still happens.
My web.xml looks like this:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>WebTest</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
My applicationContext.xml looks like this:
<?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:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:annotation-config />
<context:component-scan base-package="org.camunda.test" />
<!-- bind the process engine service as Spring Bean -->
<bean name="processEngineService" class="org.camunda.bpm.BpmPlatform"
factory-method="getProcessEngineService" />
<!-- bind the default process engine as Spring Bean -->
<bean name="processEngine" factory-bean="processEngineService"
factory-method="getDefaultProcessEngine" />
<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" />
<!-- bootstrap the process application -->
<bean id="processApplication"
class="org.camunda.bpm.engine.spring.application.SpringServletProcessApplication" />
</beans>
Thanks,
David
I'm running a single instance of Camunda, so it's homogenous. In fact, it's the installation as downloaded running on my local PC.
I've posted a small test case (Eclipse project) here http://members.optusnet.com.au/~davidrh/start-timer.zip which demonstrates the problem. When you initially build and deploy it to the standard shared engine, it works fine and the timer fires every 20 seconds. If you then stop Camunda, wait 20 seconds and then start it again you should see the issue.
It looks like the scheduler starts up and realises that the timer job is overdue to run and so executes it immediately, but this is before the web application that contains the delegate has completed deployment. If you programmatically re-start the job, or you change the process definition and re-deploy everything works fine again.
Thanks,
David
David