cancel
Showing results for 
Search instead for 
Did you mean: 

Im getting exceptions on mail task

agiledevpro
Champ in-the-making
Champ in-the-making
Hi,

I've created a mail service task that is supposed to send an email.

When I run my code I get a lot of error messages.

I've set the properies; mailServerPort, mailServerHost, mailServerUseTLS in both my activiti.cfg.xml and applicationContext.xml file.
I don't understand why I get these errors.

The properties are set to these values
mailServerPort   value="465"
mailServerHost  value="smtp.gmail.com"
mailServerUseTLS value="true"







org.activiti.engine.ActivitiException: Could not send e-mail


   at org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:75)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:54)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:66)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:116)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:407)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:105)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:54)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:54)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:45)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:53)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:90)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:571)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:566)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:349)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:98)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:37)
   at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:62)
   at org.mywebbapp.activiti.RiskProcess.startProcess(RiskProcess.java:43)
   at org.mywebbapp.javamail.Parser.parseMessage(Parser.java:25)
   at org.mywebbapp.javamail.ReadEmail.read(ReadEmail.java:63)
   at org.mywebbapp.javamail.Main.main(Main.java:13)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : localhost:25
   at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
   at org.apache.commons.mail.Email.send(Email.java:1267)
   at org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:73)
   … 66 more
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
   java.net.SocketException: Permission denied: connect
   at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
   at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
   at javax.mail.Service.connect(Service.java:288)
   at javax.mail.Service.connect(Service.java:169)
   at javax.mail.Service.connect(Service.java:118)
   at javax.mail.Transport.send0(Transport.java:188)
   at javax.mail.Transport.send(Transport.java:118)
   at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
   … 68 more
Caused by: java.net.SocketException: Permission denied: connect
   at java.net.DualStackPlainSocketImpl.connect0(Native Method)
   at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
   at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
   at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
   at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
   at java.net.PlainSocketImpl.connect(Unknown Source)
   at java.net.SocksSocketImpl.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
   at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
   at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
   … 75 more







Can anyone help?

Thanks,
4 REPLIES 4

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,


Caused by: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.SocketException: Permission denied: connect

your properties were not applied - still default one are used.

Regards
Martin

agiledevpro
Champ in-the-making
Champ in-the-making
Hi,

I'm sorry, I forgot to add the following code:
"ProcessEngine processEngine = ProcessEngineConfiguration
              .createStandaloneInMemProcessEngineConfiguration()
              .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
              .setMailServerHost("smtp.gmail.com")
              .setMailServerPort(587)
              .setMailServerUsername("workflowact@gmail.com")
              .setMailServerPassword("activiti")
              .setMailServerUseSSL(true)
              .setMailServerUseTLS(true)
              .buildProcessEngine();
     ".
When running the test, the exception now is the same except localhost is smtp.gmail.com and port is 587.

The mailServer properties in "activiti.cfg.xml" is now:


    " mailServerHost   value  smtp.gmail.com"
    "mailServerPort" value  587"
   "mailServerUsername  value workflowact@gmail.com"
    "mailServerPassword  value  activiti"
    "mailServerUseTLS   value   true"
    "mailServerUseSSL    value    true"

Any suggestions?

Thanks,

jbarrez
Star Contributor
Star Contributor
> Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : localhost:25

The error indicates your properties are not picked up.

Are you sure the that the process engine you created is actually also is being the one that is used?

agiledevpro
Champ in-the-making
Champ in-the-making
Hi,

It works now, I had to move both my activiti.cfg.xml file and my bpmn20.xml file to my projects resources. You were right, my process enigine wasn't used before.

Thank you