[jboss-user] [jBPM] - Re: How to use Email service in JBPM 5.x?

valle do-not-reply at jboss.com
Fri Aug 24 14:35:20 EDT 2012


valle [https://community.jboss.org/people/valle] created the discussion

"Re: How to use Email service in JBPM 5.x?"

To view the discussion, visit: https://community.jboss.org/message/755868#755868

--------------------------------------------------------------
thx for the quick response. I created a really simple process just using a start event, mail task and end event like you told me, but when I execute it an exception is thrown. I changed the ProcessMain.java into the following code.

public class ProcessMain {

    public static final void main(String[] args) throws Exception {
        // load up the knowledge base
        KnowledgeBase kbase = readKnowledgeBase();
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        // email
        EmailWorkItemHandler emailHandler = new EmailWorkItemHandler();
        emailHandler.setConnection("smtp.gmail.com", "465", " mailto:myusername at gmail.com myusername at gmail.com", "mypassword");
        emailHandler.getConnection();
        ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler);


        // start a new process instance
        ksession.startProcess("com.sample.bpmn.hello");
    }

    private static KnowledgeBase readKnowledgeBase() throws Exception {
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
        return kbuilder.newKnowledgeBase();
    }

}


and this is the exception message:

Exception in thread "main" org.jbpm.workflow.instance.WorkflowRuntimeException: [com.sample.bpmn.hello:1 - Email:4] -- Unable to send email
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:130)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:205)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:164)
    at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
    at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)
    at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:188)
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:303)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:168)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:138)
    at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:130)
    at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1077)
    at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:315)
    at com.sample.ProcessMain.main(ProcessMain.java:29)
Caused by: java.lang.RuntimeException: Unable to send email
    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:65)
    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:37)
    at org.jbpm.process.workitem.email.EmailWorkItemHandler.executeWorkItem(EmailWorkItemHandler.java:68)
    at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70)
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:105)
    at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:124)
    ... 14 more
Caused by: java.lang.RuntimeException: Connection failure
    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:59)
    ... 19 more
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1922)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:295)
    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:56)
    ... 19 more
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/755868#755868]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120824/fc3919cf/attachment.html 


More information about the jboss-user mailing list