jBPM mail nodes are simple nodes designed only to send mails. This time you don’t have to implement any handler or function, jBPM libraries provide nearly all you need.
In mail info tab you can set the destination e-mail address, the subject and the mail body that is going to send. This will be useful when you know destination e-mail address, orders@mycompany.com, for instance.
If you need to send mails to workflow actors, you can set a user variable in context:
executionContext.setVariable("user", workflowActor);
and configure mail info as it follows:
jBPM address resolver will check for user e-mail address from database and send him the mail, you will have to do nothing!
This is a great node but I had some requirements that it didn’t provide to me, so I re-implemented it, adding some new methods.
You can download new implementation here.
Now I can send mails using a gmail account. To explain it in a simple way, my implementation read some extra parameters from jbpm.cfg.xml file before sending the mail.
<string name="jbpm.mail.smtp.host" value="smtp.gmail.com" /> <bean name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" /> <string name="jbpm.mail.from.address" value="yourMail@gmail.com" /> <string name="jbpm.mail.user" value="yourUser@gmail.com" /> <string name="jbpm.mail.pass" value="yourPassword" /> <string name="jbpm.mail.port" value="465" /> <string name="jbpm.mail.smtp.socketFactory.port" value="465" /> <string name="jbpm.mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory" /> <string name="jbpm.mail.smtp.auth" value="true" /> <string name="jbpm.mail.smtp.starttls.enable" value="true" /> <string name="jbpm.mail.debug" value="true" /> <string name="jbpm.mail.smtp.socketFactory.fallback" value="false" /> <string name="jbpm.mail.advanced.config" value="true" /> <string name='mail.class.name' value='FastSign.mail.Mail' />
If jbpm.mail.advanced.config is set to false it works as the original mail node. Setting it to true, activates the extra parameters. In this case, 465 is gmail port, I suppose you can change it to use other system. Note that you have to define mail.class.name with the correct package.
I hope this will be useful.




April 3rd, 2008 at 2:45 pm
Hi,
you are doing here a nice work! Thanks!
One question, we can put some variable in the context like you have made:
executionContext.setVariable(”user”, workflowActor);
But do you know how to delete one?
Thanks
Marques
April 3rd, 2008 at 3:09 pm
so i’ve found…
it’s executionContext.getProcessInstance().getContextInstance().deleteVariable(”STRING”);
if someone need it like me ^-^
April 4th, 2008 at 1:30 pm
hi,
so now I’ve the problem that he doesn’t accept
executionContext.setVariable(”Variable”, myVariable);
do you have an idea?
thanks
April 4th, 2008 at 1:32 pm
hi,
so now I’ve the problem that he doesn’t accept
executionContext.setVariable(”Variable”, myVariable);
he makes an exception in hibernateException:
instance not of expected entity type: org.jbpm.conext.exe.variableInstance
do you have an idea?
i tried to convert myVariable to the type object but the errer persists…
thanks
April 4th, 2008 at 2:42 pm
What kind of type are you using? You can’t no use simple types like int. String, Integer, etc are working correctly in my projects
April 4th, 2008 at 3:01 pm
hi,
i’m using a type that i’ve defined.
example:
MyVar MVar = new MyVar(executionContext);
executionContext.setVariable(”MVar”,MVar);
but it seems to work.
I’ve tried also with String, int and with this types I had no problem.
After this I tried with executionContext.setVariable(”MVar”,MVar.toString());
and it works…but I have other problems…
and I don’t know if I can receive my variable back…
April 4th, 2008 at 3:26 pm
Does your class implements Seriarizable? You must implement it if you want hibernate save/reconstruct your objects.
April 4th, 2008 at 4:55 pm
no she was not seriarizable…that was the fault…
thanks
July 3rd, 2008 at 6:44 pm
Hi pigui, nice job, thanks to post informations to help other people.
Please, could you give a little help, somethings are not very clear to me.
When I create a new jBpm project, the jbpm.cfg.xml file is created automatically in the root of the claspath and it came empty, so uses the file org/jbpm/default.jbpm.cfg.xml to get the informations needed, right?
When I fill the jbpm.cfg.xml file with the informations that you wrote above (jbpm.mail.smtp.host, jbpm.mail.port, …) will my process automatically get the informations from the jbpm.cfg.xml file and not more from org/jbpm/default.jbpm.cfg.xml?
My jBPM version is 3.2.2.
Thank you
Regards
July 4th, 2008 at 8:14 am
@Fornachari
Hi Fornachari.
I’m always creating my complete config file and placing it inside my project.
You can load it using this function:
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseResource( “ProjectName/config/jbpm.cfg.xml”);
I hope it helps you.
January 12th, 2009 at 4:24 pm
Having problem between these lines
String mailTemplatesResource = JbpmConfiguration.Configs.getString(”resource.mail.templates”);
org.w3c.dom.Element mailTemplatesElement = XmlUtil.parseXmlResource(mailTemplatesResource, true);
I am using JBPM 3.3.0 GA, can u modify it..
signature is: public static Document parseXmlResource(String resource, boolean isJbpmConfiguration) {
April 3rd, 2009 at 1:22 am
Hi,
Thank for you post.
I have a problem. The system announced to me that he couldn’t resolve class FastSign.mail.Mail.
Can you tell me that class is your own or it come from some jar library? and please tell me its function?
Thank so much!
April 3rd, 2009 at 7:46 am
Hi NautilusVN
I developed this class some time ago and it worked fine. Where did you place it? You will have to adapt the package to your path or place it inside a FastSign/mail folder.
June 19th, 2009 at 1:32 pm
Can you keep entire project zip/war file on the site, to download?
Or can you plz email it to me?
Thanks
Shankar
June 22nd, 2009 at 9:31 am
@shankar
Which project?
June 23rd, 2009 at 6:35 am
Hi pigui, I was asking about a sample project which uses mail node.
Problem, I am facing is as below:
I have configured value for property “jbpm.mail.port” in jbpm.cfg.xml file.
But this port is not getting used while sending email.
I am getting below error:
Caused by: javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: MUM-EXCH01.shritech.corp, port: 25, response: -1
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
June 23rd, 2009 at 11:55 am
I’m sorry I can not share the code of that project.
June 24th, 2009 at 10:16 am
At least, let me know:
Why the port 25 is getting used instead of the port I configured?
June 25th, 2009 at 8:16 am
Did you set
jbpm.mail.advanced.config" = "true"
?
June 26th, 2009 at 12:00 pm
resolved the problem.
The problem was with mail.class.name configuration.
Thank u.
July 1st, 2009 at 11:57 am
@shankar
Perfect
January 19th, 2010 at 11:00 am
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseResource( “ProjectName/config/jbpm.cfg.xml”);
How to set the JBPMConfiguration in the jbpm4.0 as there is no method called parseResource() in it.
Please help me in mail.properties configuration in jbpm 4.0
January 19th, 2010 at 11:02 am
i am getting the following errors:
[DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd@1deba30
java.lang.NullPointerException
at org.jbpm.pvm.internal.email.impl.MailSessionImpl.send(MailSessionImpl.java:47)
at org.jbpm.jpdl.internal.activity.MailActivity.perform(MailActivity.java:44)
at org.jbpm.jpdl.internal.activity.JpdlAutomaticActivity.execute(JpdlAutomaticActivity.java:15)
at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
……….
……
………
………
January 19th, 2010 at 1:53 pm
@Anand
I’m not working with jBPM 4.0 so I can’t help you. I’m sorry.