AnsweredAssumed Answered

TimerBoundaryEvent - Not recognizing Spring Bean in Loop

Question asked by tidetom on Jun 3, 2011
Latest reply on Jun 7, 2011 by tidetom
Hi all,

I have a tricky problem that I've been trying to solve all day, and can't seem to figure out.  Hoping you can help…

I have a TimerBoundaryEvent placed on a Java Receive Task in my process flow.  The flow itself is somewhat of a loop.  The way that my process flow works is as follows: (simplified for forum purposes):
    1. Start Task
    2. Service Task (invokes Spring Bean "myAdapter.doSomething()" in an expression)
    3. XOR Gateway (checks whether we have what we need.  If not, continues to java receive task.  If so, goes to the End Task)
    4. Java Receive Task (waits indefinitely, until interrupted by Timer Boundary Event)
    5. Timer Boundary Event (interrupts Java Receive Task)
    6. XOR Gateway (Determine whether we've reached a maximum number of loops. If not, continue back up to the Service Task in step #2.  If so, goes to the End Task)
    7. End Task
The problem that I'm having is that sometimes when looping back to the service task, the Job fails because it doesn't recognize "myAdapter" (my Spring bean).  Note that this is <i>very</i> inconsistent.  From execution to execution, it might change.  On one execution, it will recognize the adapter the first time it enters the service (before looping the first time) and then will fail on the second loop.  The next time I run my unit test, it will succeed on the first and second loop, but fail on the third loop, etc.  I have not yet seen it get to a fourth loop.

The error that I receive is a standard one I'd expect to see when not properly specifying the bean:

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'myAdapter'
        at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
        at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)

But note that this error DOES NOT OCCUR the first time I enter the Service Task wherein "myAdapter.doSomething()" is invoked … only on subsequent calls after looping back to that Service Task.

I was thinking that it had something to do with the loop itself … maybe looping back to a task that has already been created, used, and completed is not allowed?  Maybe I should pull the "looping" out into it's own Spring Bean, use my own threading/executor, and not use the TimerBoundaryEvent at all?

Any advice or comments would be very much appreciated.  I can provide more information on this issue if needed.

Thanks,
Tom

Outcomes