Start Event timer exception on server restart when using expression delegate

843 views
Skip to first unread message

dav...@optusnet.com.au

unread,
Oct 29, 2013, 1:45:10 AM10/29/13
to camunda-...@googlegroups.com, david...@auspost.com.au
I have a process definition where the start event is a timer. The timer cycle is set to "R/PT20S", so it repeats every 20 seconds. The start event is followed by a Service Task which delegates to a Spring bean.

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.

Christian Lipphardt

unread,
Oct 29, 2013, 6:04:56 AM10/29/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Hi,

do you use the shared engine in tomcat or an embedded one?
If you use the shared engine, do you use the SpringServletProcessApplication to bootstrap?

Cheers
Christian

dav...@optusnet.com.au

unread,
Oct 29, 2013, 6:23:22 PM10/29/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Hi Christian,

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

Daniel Meyer

unread,
Oct 30, 2013, 10:55:46 AM10/30/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Hi Dave,

The configuration option "jobExecutorDeploymentAware" shoul take care of this problem: http://docs.camunda.org/latest/guides/user-guide/#process-engine-the-job-executor-job-execution-in-heterogeneous-clusters
If it does not it is a bug. We will try to reproduce this and get back to you. 

Cheers,
Daniel Meyer

dav...@optusnet.com.au

unread,
Oct 30, 2013, 6:12:39 PM10/30/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Hi Daniel,

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

Message has been deleted

Christian Lipphardt

unread,
Oct 31, 2013, 7:48:06 AM10/31/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Hi David,

I can confirm it as a bug and created CAM-1446 for it.

Cheers
Christian

Christian Lipphardt

unread,
Oct 31, 2013, 1:41:28 PM10/31/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Hi David,

the issue has been resolved and your test case runs successfully.
Thanks for creating it!

Cheers
Christian

dav...@optusnet.com.au

unread,
Oct 31, 2013, 9:23:01 PM10/31/13
to camunda-...@googlegroups.com, david...@auspost.com.au, dav...@optusnet.com.au
Wow - that was quick. Thanks for the prompt response.

David

Daniel Meyer

unread,
Nov 4, 2013, 2:55:59 AM11/4/13
to camunda-...@googlegroups.com, david...@auspost.com.au
Hi David,

the problem was as follows:
- when using the camunda BPM tomcat distribution, the process engine and
the job Executor are started as part of the tomcat server lifecycle
_before_ any application is deployed.
- as a result the job executor starts to acquire jobs before the
application required for executing them is deployed.
- we introduced the "deployment aware" mode for the jobexecutor where jobs
are only executed if they have a "DEPLOYMENT_ID_" contained in the list of
currently active deployments on that process engine.
- The bug was that the DEPLOYMENT_ID_ was not set for timer start events.
It was only set for timer intermediate events and asynchronous
continuations.

The "deployment aware mode" is interesting in two different settings:
* you can used it for handling heterogeneous clusters where different
applications are deployed on different nodes (not the case here)
* but it is also required for multi-application deployments where a single
process engine instance is responsible for servicing multiple applications
which can be redeployed individually without shutting down the process
engine itself.

Cheers,
Daniel Meyer

-----Urspr�ngliche Nachricht-----
Von: camunda-...@googlegroups.com
[mailto:camunda-...@googlegroups.com] Im Auftrag von
dav...@optusnet.com.au
Gesendet: Freitag, 1. November 2013 02:23
An: camunda-...@googlegroups.com
Cc: david...@auspost.com.au; dav...@optusnet.com.au
Betreff: [camunda-bpm-users] Re: Start Event timer exception on server
restart when using expression delegate

Wow - that was quick. Thanks for the prompt response.

David

--
You received this message because you are subscribed to the Google Groups
"camunda BPM users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/camunda-bpm-users/4546622e-bd96-45dd-b63
0-ab36363c6394%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages