1 2 Previous Next 18 Replies Latest reply on Jun 2, 2015 1:45 AM by sherryyur

    Email Service Task - "Cannot find work item handler for Email"

    minamesephy

      Hello, I'm a beginner with jBPM and I just wanted to do some experimentation with the email task.

      Right now it just looks like this: (i'm using the KIE workbench running on localhost)

      screenshot.jpg

      It deploys fine, but when I try to start the process by going into the list of process definitions and then clicking the "play" button for this process, it says:

       

      Process Instances failed to start: [ServiceTest.mainProcess:21 - Email:3] -- Could not find work item handler for Email

       

      I guess I know that I'm missing something here - but what? Am I misunderstanding what I've seen online? Because I thought you could just use the task node, plug in your values, and it should all work assuming you have a mail server set up properly. Any advice would be appreciated!

        • 1. Re: Email Service Task - "Cannot find work item handler for Email"
          josdel

          Hi Tali,

           

          You should register the workitem Handler for Service Tasks. For email service task

           

          StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

          ksession.getWorkItemManager().registerWorkItemHandler("Notification", new NotificationWorkItemHandler());

           

          HTH

          • 2. Re: Email Service Task - "Cannot find work item handler for Email"
            lakshjee

            Hi Josny,

            from where do we need to register the work item handler. Please update the path please.

            Thank you.

            • 3. Re: Email Service Task - "Cannot find work item handler for Email"
              swiderski.maciej

              check section 5.4.4.2 of configuration in docs. There are few ways you can select to register handlers where the simplest one is to edit CustomWorkItemHandlers.conf finale that is inside kie-wb/WEB-INF/classes/META-INF

               

              HTH

              • 4. Re: Email Service Task - "Cannot find work item handler for Email"
                lakshjee

                Hi,

                Thanks for your quick response. I have edited my CustomWorkItemHandlers.conf as follows. But still get the same error. Please assist me since i am a newbie.

                 

                [

                  "Log": new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler(),

                  "WebService": new org.jbpm.process.workitem.webservice.WebServiceWorkItemHandler(ksession),

                  "Rest": new org.jbpm.process.workitem.rest.RESTWorkItemHandler()

                ;

                StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

                ksession.getWorkItemManager().registerWorkItemHandler("Notification", new NotificationWorkItemHandler())

                 

                 

                ]

                • 5. Re: Email Service Task - "Cannot find work item handler for Email"
                  swiderski.maciej

                  you should define another mapping for handler and not put code into the conf file e.g.

                  "Email" : new org.jbpm.process.workitem.email.EmailWorkItemHandler("host", "port", "user", "password")


                  HTH

                  • 6. Re: Email Service Task - "Cannot find work item handler for Email"
                    lakshjee

                    Thanks for the response. I edited the CustomWorkItemHandlers.conf as u said. now i get the following error message.Untitled.jpg

                    • 7. Re: Email Service Task - "Cannot find work item handler for Email"
                      swiderski.maciej

                      check your server log as there might be reason why it cannot send email. Please make sure that you specified correct settings for your mail server in the conf file - replacing host with actual host name or IP address of your mail server, and same for port, user and password.

                       

                      HTH

                      • 8. Re: Email Service Task - "Cannot find work item handler for Email"
                        lakshjee

                        Thanks.  Your assistance is really helpful for me

                        This is how i edited conf file;

                        "Email" : new org.jbpm.process.workitem.email.EmailWorkItemHandler("smtp.gmail.com", "587", "<username>@gmail.com", "<password>")

                         

                        and my server log says;

                        java.lang.NullPointerException

                        at javax.mail.util.ByteArraydataSource etc......

                        • 9. Re: Email Service Task - "Cannot find work item handler for Email"
                          lakshjee

                          Hi

                          I put jbpm-workitems, javax.mail and javax.activation jars in the lib folder of the AS and the include

                          "Email" : new org.jbpm.process.workitem.email.EmailWorkItemHandler("smtp.gmail.com", "587", "<username>@gmail.com", "<password>") to CustomWorkItemHandlers.conf file.  But when I running the process definition i get the following error message;

                          [Process Instances failed to start: [emailp.email:4 - Email:2] -- java.lang.RuntimeException: Unable to send email ]

                          and my server log says;

                          Caused by: java.lang.RuntimeException: Unable to send email

                                  at org.jbpm.process.workitem.email.SendHtml.fillMessage(SendHtml.java:14

                          7) [jbpm-workitems-6.0.1.Final.jar:6.0.1.Final]

                                  at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:59) [

                          jbpm-workitems-6.0.1.Final.jar:6.0.1.Final]

                                  ... 73 more

                          Caused by: java.lang.NullPointerException

                                  at javax.mail.util.ByteArrayDataSource.<init>(ByteArrayDataSource.java:1

                          41) [mail-1.4.4.jar:1.4.4]

                                  at org.jbpm.process.workitem.email.SendHtml.fillMessage(SendHtml.java:13

                          9) [jbpm-workitems-6.0.1.Final.jar:6.0.1.Final]

                           

                          Please assist me.

                          • 10. Re: Email Service Task - "Cannot find work item handler for Email"
                            swiderski.maciej

                            that means you have not specified body of your email that should be set on the email task. Please populate all the fields for Email task and try again.

                             

                            HTH

                            • 11. Re: Email Service Task - "Cannot find work item handler for Email"
                              lakshjee

                              Thanks for your prompt response.

                              Now i get following message i think it os because of im working in a secured network environment.

                               

                              1. java.net.UnknownHostException: smtp.gmail.com

                                      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java

                              :178) [rt.jar:1.7.0_11]

                                      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) [rt.jar:1.

                              1. 7.0_11]

                               

                              Does this work if I change my network environment?

                               

                              Thank you.

                              • 12. Re: Email Service Task - "Cannot find work item handler for Email"
                                swiderski.maciej

                                yes, that is pure communication error caused by your network settings as the external server cannot be found, make sure you can access that server from the machine where jbpm is running and that should solve the issue.

                                 

                                HTH

                                • 13. Re: Email Service Task - "Cannot find work item handler for Email"
                                  lakshjee

                                  Hi

                                  <subsystem xmlns="urn:jboss:domain:mail:1.0">

                                              <mail-session jndi-name="java:jboss/mail/Default">

                                                  <smtp-server ssl="true" outbound-socket-binding-ref="mail-smtp">

                                                      <login name="@gmail.com" password="*****f"/>

                                                  </smtp-server>

                                              </mail-session>

                                   

                                  <outbound-socket-binding name="mail-smtp">

                                              <remote-destination host="smtp.gmail.com" port="587"/>

                                          </outbound-socket-binding>

                                  but still i get the server log error

                                   

                                  Caused by: org.jbpm.bpmn2.handler.WorkItemHandlerRuntimeException: java.lang.RuntimeException: Unable to send email

                                    at org.jbpm.process.workitem.AbstractLogOrThrowWorkItemHandler.handleException(AbstractLogOrThrowWorkItemHandler.java:40) [jbpm-workitems-6.0.0.Final.jar:6.0.1.Final]

                                    at org.jbpm.process.workitem.AbstractLogOrThrowWorkItemHandler.handleException(AbstractLogOrThrowWorkItemHandler.java:23) [jbpm-workitems-6.0.0.Final.jar:6.0.1.Final]

                                    at org.jbpm.process.workitem.email.EmailWorkItemHandler.executeWorkItem(EmailWorkItemHandler.java:75) [jbpm-workitems-6.0.0.Final.jar:6.0.0.Final]

                                    at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:56) [drools-persistence-jpa-6.0.1.Final.jar:6.0.1.Final]

                                    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:124) [jbpm-flow-6.0.1.Final.jar:6.0.1.Final]

                                    ... 71 more

                                  Caused by: java.lang.RuntimeException: Unable to send email

                                    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:73) [jbpm-workitems-6.0.0.Final.jar:6.0.0.Final]

                                    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:45) [jbpm-workitems-6.0.0.Final.jar:6.0.0.Final]

                                    at org.jbpm.process.workitem.email.EmailWorkItemHandler.executeWorkItem(EmailWorkItemHandler.java:69) [jbpm-workitems-6.0.0.Final.jar:6.0.0.Final]

                                    ... 73 more

                                  Caused by: java.lang.RuntimeException: Connection failure

                                    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:67) [jbpm-workitems-6.0.0.Final.jar:6.0.0.Final]

                                    ... 75 more

                                  Caused by: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. vu3sm6577316igc.6 - gsmtp

                                   

                                   

                                    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057) [mail-1.4.4.jar:1.4.4]

                                    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1580) [mail-1.4.4.jar:1.4.4]

                                    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1097) [mail-1.4.4.jar:1.4.4]

                                    at org.jbpm.process.workitem.email.SendHtml.sendHtml(SendHtml.java:65) [jbpm-workitems-6.0.0.Final.jar:6.0.0.Final]

                                    ... 75 more

                                  • 14. Re: Email Service Task - "Cannot find work item handler for Email"
                                    rafaelcba

                                    Hi swiderski.maciej!

                                     

                                    Is possible to pass the Work Item Handler constructor's parameters through the Task DataInputs?

                                    For example the Email Handler constructor receives: host, port, user and password parameters. But they are static in the CustomWorkItemHandlers.conf descriptor. Would be nice if the Handlers could be injected in runtime or be able to set the parameters througn Task DataInput values.

                                    1 2 Previous Next