Dhaval Shah [
https://community.jboss.org/people/shahdhaval2020] created the discussion
"Re: How to use Email service in JBPM 5.x?"
To view the discussion, visit:
https://community.jboss.org/message/793190#793190
--------------------------------------------------------------
Hey i used the same code as u had written but i am getting this error what does this
mean????
i have used email service task in process design .....i.e., start node -> email service
task -> end node..
can u plz help me out
===============================
MyProcessmain.java=======================================
package com.sample;
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.runtime.StatefulKnowledgeSession;
import org.jbpm.process.workitem.email.EmailWorkItemHandler;
/**
* This is a sample file to launch a process.
*/
public class ProcessMain {
public static final void main(String[] args) throws Exception {
// // load up the knowledge base
// KnowledgeBase kbase = readKnowledgeBase();
// StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
// // start a new process instance
// ksession.startProcess("com.sample.bpmn.hello");
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
EmailWorkItemHandler emailHandler = new EmailWorkItemHandler();
emailHandler.setConnection("smtp.gmail.com", "587",
" mailto:shahdhaval2020@gmail.com shahdhaval2020(a)gmail.com",
"com!@#$%");
emailHandler.getConnection().setStartTls(true);
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();
}
// load up the knowledge base
}
=========================sample.bpmn=============================================
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="
http://www.jboss.org/drools
http://www.jboss.org/drools"
typeLanguage="
http://www.java.com/javaTypes
http://www.java.com/javaTypes"
expressionLanguage="
http://www.mvel.org/2.0
http://www.mvel.org/2.0"
xmlns="
http://www.omg.org/spec/BPMN/20100524/MODEL
http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.omg.org/spec/BPMN/20100524/MODEL
http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
xmlns:g="
http://www.jboss.org/drools/flow/gpd
http://www.jboss.org/drools/flow/gpd"
xmlns:bpmndi="
http://www.omg.org/spec/BPMN/20100524/DI
http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="
http://www.omg.org/spec/DD/20100524/DC
http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="
http://www.omg.org/spec/DD/20100524/DI
http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="
http://www.jboss.org/drools
http://www.jboss.org/drools">
<process processType="Private" isExecutable="true"
id="com.sample.bpmn.hello" name="Hello World" >
<!-- nodes -->
<startEvent id="_1" name="StartProcess" />
<endEvent id="_3" name="EndProcess" >
<terminateEventDefinition/>
</endEvent>
<task id="_4" name="Email" tns:taskName="Email" >
<ioSpecification>
<inputSet>
</inputSet>
<outputSet>
</outputSet>
</ioSpecification>
</task>
<!-- connections -->
<sequenceFlow id="_4-_3" sourceRef="_4"
targetRef="_3" />
<sequenceFlow id="_1-_4" sourceRef="_1"
targetRef="_4" />
</process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.sample.bpmn.hello" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="16" y="16" width="48"
height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="345" y="38" width="48"
height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="115" y="37" width="100"
height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_4-_3" >
<di:waypoint x="165" y="61" />
<di:waypoint x="369" y="62" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_1-_4" >
<di:waypoint x="40" y="40" />
<di:waypoint x="165" y="61" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
==============================================
And when i run this i am getting following output on console
=====>>>>
OUTPUT
==================
Exception in thread "main" org.jbpm.workflow.instance.WorkflowRuntimeException:
[com.sample.bpmn.hello:1 - Email:4] -- Email must have one or more to adresses
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:33)
Caused by: java.lang.RuntimeException: Email must have one or more to adresses
at
org.jbpm.process.workitem.email.EmailWorkItemHandler.createEmail(EmailWorkItemHandler.java:86)
at
org.jbpm.process.workitem.email.EmailWorkItemHandler.executeWorkItem(EmailWorkItemHandler.java:67)
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
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/793190#793190]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]