AnsweredAssumed Answered

Expression does not work for time cycle in timer event

Question asked by sensisdev on Oct 15, 2012
Latest reply on Apr 22, 2014 by frederikheremans1
Hi I am using Activiti 5.10

I have read the Activiti doco and it says the expression can be used for time cycle in timer event:
e,g.
     <timerEventDefinition>
      <timeDuration>${duration}</timeDuration>
    </timerEventDefinition>

My scenario is we want to read the time cycle from our configuration service instead of hard coding it.

My Activiti looks like this:

    <startEvent id="timerstartyelpendofdayreport" name="Timer Start Yelp End Of Day Report">
      <timerEventDefinition>
        <timeCycle>${configurationRetriever.getTimeCycle()}</timeCycle>
      </timerEventDefinition>
    </startEvent>

The configurationRetriever.getTimeCycle() will return cron expression string.

The problem is the activiti process can not be deployed and I have got the following error:

org.activiti.engine.ActivitiException: Failed to parse cron expression: ${configurationRetriever.getTimeCycle()}
    at org.activiti.engine.impl.calendar.CycleBusinessCalendar.resolveDuedate(CycleBusinessCalendar.java:37)
    at org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl.prepareTimerEntity(TimerDeclarationImpl.java:128)
    at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.addTimerDeclarations(BpmnDeployer.java:182)
    at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:149)
    at org.activiti.engine.impl.persistence.deploy.DeploymentCache.deploy(DeploymentCache.java:38)
    at org.activiti.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:42)
    at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:59)
    at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:31)
    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.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:54)
    at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:106)
    at au.com.sensis.fabric.vendormanagement.process.yelp.Vendor20630FulfillmentEndOfDayReportTest.deploy(Vendor20630FulfillmentEndOfDayReportTest.java:76)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.text.ParseException: Unexpected character: $
    at org.activiti.engine.impl.calendar.CronExpression.storeExpressionVals(CronExpression.java:582)
    at org.activiti.engine.impl.calendar.CronExpression.buildExpression(CronExpression.java:360)
    at org.activiti.engine.impl.calendar.CronExpression.<init>(CronExpression.java:277)
    at org.activiti.engine.impl.calendar.CycleBusinessCalendar.resolveDuedate(CycleBusinessCalendar.java:32)
    … 48 more

Could anyone please give me a hand?

Many thanks

Sean

Outcomes