CMDBuild Forum

Problema invio mail da workflow

Buongiorno a tutti,

 

ho agganciato con successo shark al cmdbuild 2.2.2 e riesco a far girare i workflow creati con il TWE.

Sto avendo problemi nel definire un'attività "script" che invii una semplice email di test.

La "activity" di tipo "task script" utilizza questo codice:

 

cmdb.newMail() 

  .withFrom(maskedpenguin@mydomain.com") 

  .withTo(myrecipient@mydomain.com")

  .withSubject("TEST1")

  .withContent("Mail content TEST1")

  .send();

 

Sul log cmdbuild.log ho queste (ultime) righe al verificarsi dell'errore al passo in cui il flow dovrebbe inviare la mail.

 

INFO  2014-12-16 17:18:12 [cmdbuild] trying to login user workflow with group null

INFO  2014-12-16 17:18:12 [workflow] pushing event 'WorkflowEvent[type=UPDATE,processDefinitionId=Process_test2,processInstanceId=207_Package_test2_Process_test2]' for session '75'

WARN  2014-12-16 17:18:13 [sql     ] cannot get content of column 'test2#FlowStatus#Description'

WARN  2014-12-16 17:18:13 [sql     ] cannot get content of column 'test2#FlowStatus#Description'

INFO  2014-12-16 17:18:13 [workflow] updating activity instance '19_207_Package_test2_Process_test2_UpdOS' for process 'test2'

WARN  2014-12-16 17:18:13 [sql     ] cannot get content of column 'test2#FlowStatus#Description'

INFO  2014-12-16 17:18:13 [workflow] advancing activity instance '19_207_Package_test2_Process_test2_UpdOS' for process 'test2'

INFO  2014-12-16 17:18:13 [cmdbuild] trying to login user workflow with group null

INFO  2014-12-16 17:18:13 [workflow] pushing event 'WorkflowEvent[type=UPDATE,processDefinitionId=Process_test2,processInstanceId=207_Package_test2_Process_test2]' for session '79'

ERROR 2014-12-16 17:18:14 [jsonrpc ] A org.cmdbuild.workflow.CMWorkflowException occurred calling method class org.cmdbuild.servlets.json.Workflow.saveActivity: org.enhydra.shark.api.internal.toolagent.ToolAgentGeneralException: Sourced file: eval stream : Method Invocation send

 

A prima vista sembra che il problema sia nell'invocazione del metodo "send" sull'oggetto MAIL creato nel workflow, ma non saprei cercare ulteriormente in quanto a pag 66 del manuale in inglese del workflow è presente un estratto di codice praticamente identico.

 

Grazie a tutti in anticipo, saluti,

             g.caglio

 

 

 

 

Breve aggiunta.

 
con il frammento di codice del manuale 
 
cmdb.newMail()
.withFrom(maskedpenguin@mydomain.com")
.withTo(g.caglio@mydomain.com")
.withCc(altroindirizzoemail@mydomain.com")
.withSubject("Mail subject - OK")
.withContent("Mail content - OK")
.send();
 
sono riuscito a vedere nel log che lo shark tentava di spedire al server "smtp.together.at".
Dalla documentazione di cui al link (http://www.mirrorservice.org/sites/downloads.sourceforge.net/s/sh/sharkwf/shark/5.1-1/tws-5.1-1.doc.pdf) ho identificato le chiavi opportune da modificare nel file Shark.conf :
Riporto le chiavi che ho dovuto modificare -a beneficio di altri utenti- per riflettere quanto nella mia infrastruttura : 
 
DefaultMailMessageHandler.SMTPMailServer=<ip_server_mail>
DefaultMailMessageHandler.SourceAddress=cmdb_workflow_agent@miodominio.com
 
# il mio relay di posta non richiede autenticazione
DefaultMailMessageHandler.useAuthentication=false
 
# utilizziamo plain SMTP
DefaultMailMessageHandler.starttls=false
# SSL
DefaultMailMessageHandler.useSSL=false
# debug - per info sulla connessione al server
DefaultMailMessageHandler.debug=true
 
 
Fatto questo ho riavviato il tomcat e l'invio mail, con il codice di cui sopra, ha funzionato.
Tuttavia ho provato anche ad inviare un'altra mail con questo frammento di codice :
 
cmdb.newMail()
.withTo(g.caglio@mydomain.com")
.withCc(altroindirizzoemail@mydomain.com")
.withSubject("Mail subject - OK")
.withContent("Mail content - OK")
.send();

Senza cioè specificare il mittente, ma l'invio non è andato a buon fine (sembra non utilizzare il default?).
L'eccezione nel log è  (limito lo stacktrace per leggibilità):
2014-12-17 14:31:51,117: AxisFault:
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: org.enhydra.shark.api.internal.toolagent.ToolAgentGeneralException: Sourced file: eval stream : Method Invocation send
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}stackTrace:Sourced file: eval stream : Method Invocation send : at Line: 6 : in file: eval stream : .send ( )
 
Target exception: org.cmdbuild.common.api.mail.MailException: javax.mail.internet.AddressException: Illegal address in string ``,''
 
        at bsh.BSHPrimarySuffix.doName(Unknown Source)
        at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at org.enhydra.shark.toolagent.BshToolAgent.invokeApplication(Unknown Source)
        at org.cmdbuild.shark.toolagent.OverriddableDefaultToolAgent.invoke(OverriddableDefaultToolAgent.java:202)
        at org.cmdbuild.shark.toolagent.CmdbuildDefaultToolAgent.invoke(CmdbuildDefaultToolAgent.java:70)
        at org.cmdbuild.shark.toolagent.OverriddableDefaultToolAgent.invokeApplication(OverriddableDefaultToolAgent.java:87)
        at org.enhydra.shark.toolagent.StandardToolAgentManager.invokeToolAgent(Unknown Source)
        at org.enhydra.shark.StandardToolActivityHandler$ToolRunner.invokeApplication(Unknown Source)
[...]
        at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
        at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
        ... 21 more
Caused by: Sourced file: eval stream : Method Invocation send : at Line: 6 : in file: eval stream : .send ( )
 
Target exception: org.cmdbuild.common.api.mail.MailException: javax.mail.internet.AddressException: Illegal address in string ``,''
 
        at bsh.BSHPrimarySuffix.doName(Unknown Source)
        at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        ... 48 more
 
Sembra quindi indispensabile esplicitare il mittente anche nel codice.
 
 
      grazie, saluti, 
 
                giuliano