rehankhan
2013-01-16 12:40:43 UTC
rehankhan [https://community.jboss.org/people/rehankhan] created the discussion
"Want to send email using jbpm5 but got some error"
To view the discussion, visit: https://community.jboss.org/message/792304#792304
--------------------------------------------------------------
   ProcessMain.java
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
import org.jbpm.process.workitem.email.EmailWorkItemHandler;
public class ProcessMain {
   public static final void main(String[] args) {
       try {
           // load up the knowledge base
           KnowledgeBase kbase = readKnowledgeBase();
           StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
           EmailWorkItemHandler emailHandler = new EmailWorkItemHandler();
            emailHandler.setConnection("smtp.gmail.com", "587", " mailto:***@gmail.com ***@gmail.com", "mypassword");
            emailHandler.getConnection().setStartTls(true);
           ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler);
           ksession.startProcess("com.sample.bpmn");
           System.out.println("Process started ...");  Â
          // emailHandler.getConnection();
       } catch (Throwable t) {
           t.printStackTrace();
       }
   }
   private static KnowledgeBase readKnowledgeBase() throws Exception {
       KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
       kbuilder.add(ResourceFactory.newClassPathResource("mail.bpmn"), ResourceType.BPMN2);
       return kbuilder.newKnowledgeBase();
   }
}
following error is given
come
org.jbpm.workflow.instance.WorkflowRuntimeException: [com.sample.bpmn:1 - Email:2] -- Unable to send email
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:132)
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279)
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238)
   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:126)
   at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
   at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:194)
   at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:309)
   at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:170)
   at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:140)
   at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:132)
   at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1093)
   at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:315)
   at ProcessMain.main(ProcessMain.java:38)
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:107)
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126)
   ... 14 more
Caused by: java.lang.RuntimeException: Connection failure
   at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:59)
   ... 19 more
Caused by: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. a4sm12928682pax.25
   at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
   at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
   at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
   at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:57)
   ... 19 more
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/792304#792304]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
"Want to send email using jbpm5 but got some error"
To view the discussion, visit: https://community.jboss.org/message/792304#792304
--------------------------------------------------------------
   ProcessMain.java
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
import org.jbpm.process.workitem.email.EmailWorkItemHandler;
public class ProcessMain {
   public static final void main(String[] args) {
       try {
           // load up the knowledge base
           KnowledgeBase kbase = readKnowledgeBase();
           StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
           EmailWorkItemHandler emailHandler = new EmailWorkItemHandler();
            emailHandler.setConnection("smtp.gmail.com", "587", " mailto:***@gmail.com ***@gmail.com", "mypassword");
            emailHandler.getConnection().setStartTls(true);
           ksession.getWorkItemManager().registerWorkItemHandler("Email", emailHandler);
           ksession.startProcess("com.sample.bpmn");
           System.out.println("Process started ...");  Â
          // emailHandler.getConnection();
       } catch (Throwable t) {
           t.printStackTrace();
       }
   }
   private static KnowledgeBase readKnowledgeBase() throws Exception {
       KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
       kbuilder.add(ResourceFactory.newClassPathResource("mail.bpmn"), ResourceType.BPMN2);
       return kbuilder.newKnowledgeBase();
   }
}
following error is given
come
org.jbpm.workflow.instance.WorkflowRuntimeException: [com.sample.bpmn:1 - Email:2] -- Unable to send email
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:132)
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279)
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238)
   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:126)
   at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35)
   at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:194)
   at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:309)
   at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:170)
   at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:140)
   at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:132)
   at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1093)
   at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:315)
   at ProcessMain.main(ProcessMain.java:38)
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:107)
   at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126)
   ... 14 more
Caused by: java.lang.RuntimeException: Connection failure
   at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:59)
   ... 19 more
Caused by: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. a4sm12928682pax.25
   at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
   at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
   at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
   at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:57)
   ... 19 more
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/792304#792304]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]