Jas Lam [
http://community.jboss.org/people/lamj1] replied to the discussion
"EventListener questions"
To view the discussion, visit:
http://community.jboss.org/message/533587#533587
--------------------------------------------------------------
I am experiencing this same exact problem where I can not get a handle on the task when my
event listener is triggered.
So I dig into jBPM code that handles the <notification/> tag. See section for
description of this tag
h4. 6.2.6.6. e-mail support in tasks
http://docs.jboss.org/jbpm/v4/userguide/html_single/#task
http://docs.jboss.org/jbpm/v4/userguide/html_single/#task
<task assignee="ssoa" form="tasks/downloadData.htm"
g="155,11,123,60" name="DownloadData">
<notification/>
</task>
This would trigger the org.jbpm.jpdl.internal.activity.MailListener class to send out an
email to the assigned user
To find the current task, the MailListener notify method has the following code:
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
DbSession dbSession = environment.get(DbSession.class);
TaskImpl task = dbSession.findTaskByExecution(execution);
When i stepped through the code in debug mode. the +task+ variable is populated with the
newly created task. I also noticed that no entry in the DB has been created for the task
yet. Hence using query API won't return any task. It is looking great till this
point.
THEN THE PROBLEM IS:
When i tried to insert the above Java code in implementing my listener.
TaskImpl task = dbSession.findTaskByExecution(execution); //RETURN NULL!!!
It always returns NULL.
As I stepped through debug mode. I noticed my listener code is invoked first before the
MailListener notify method. I watched the +execution+ variable and they are the same when
in MailListener and myListener. The execution variable already has an associating task.
Not sure why dbSession.findTaskByExecution() kept returning NULL.
Thanks in advance for any help!
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/533587#533587]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]