[問題] 關於IBM lotus Notes的Exception補抓
各位前輩好:
小弟目前的專案有一個需求,那就是使用Notes來寄公司的內部信。
小弟的實做方式是使用Notes Client的API調用Notes Client來達到寄信功能。
目前這支的程式已經實做出來了,而且能正常運作。
然而,在 RESTful Web Service 的程式中,調用那一支寄信的程式,使用try/catch
卻補抓不到 NotesException的異常訊息。
程式碼節錄如下:
(1)MailSent程式碼節錄:
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.EmbeddedObject;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.RichTextItem;
import lotus.domino.RichTextStyle;
import lotus.domino.Session;
import lotus.domino.NotesException;
public class MailSent extends NotesThread{
String pwd;
String attche;
String NameNsf;
String Subject;
String SentTo;
String Name;
Document MailContent =null;
Session session= null;
public MailSent(String pwd,String attche,String NameNsf,String subject,String
sent){
this.pwd= pwd;
this.attche= attche;
this.NameNsf = NameNsf;
this.Subject=subject;
this.SentTo=sent;
}
public void runNotes()throws NotesException {
session = NotesFactory.createSessionWithFullAccess(pwd);
.
.
.
(省略)
MailContent.sent(false,SentTo);
}
}
------------------------------------------------------------------
(2)RESTful Web API程式節錄:
@GET
@Path("/SendMail/{SendTo}")
public Response MailSend(@PathParam("SendTo") String SendTo){
String pwd = config.GetValue("MailPwd");
String NameNsf = config.GetValue("MailNameNsf");
String Subject="xxxxx";
String attch="c:\\xx.doc";
try{
MailSent mailSend = new
MailSent(pwd,attch,NameNsf,Subject,SendTo);
mailSend.start();
return Response.ok("MailSend_Ok").build();
}catch(NotesException e){
log.error("Mail Send Failed!"+e.text);
return Response.status(500).entity(e.text).build();
}
}
----------------------------------------------------------------------
問題就是出在上述的 RESTful Web API中調用寫好的MailSent的程式,卻補抓不到
NotesException的異常訊息(若異常發生時。)小弟認為應該是出在該支MailSent
是一支執行緒,因此若發生異常時在web api中才會補抓不到異常訊息。若要在上述
RESTful的程式中補抓NotesException的訊息,是否有方法可行呢?!
--
陰律無情!是的,犯邪淫者,小如手淫、婚前性行為
均會遭折福減壽之惡報。國考者更不能犯淫邪,
否則文昌帝君會除去功名,不信請看此懺悔文:
http://lustwarn.blogspot.tw/
陰律無情!是的,犯邪淫者,若不懺悔發心改過永不再犯,
死後必入邪淫地獄,不信請看;http://goo.gl/tchBZY
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 14.188.239.227
※ 文章網址: https://www.ptt.cc/bbs/java/M.1455261443.A.E27.html
推
02/13 11:53, , 1F
02/13 11:53, 1F
→
02/13 11:54, , 2F
02/13 11:54, 2F
→
02/13 11:55, , 3F
02/13 11:55, 3F
→
02/13 11:55, , 4F
02/13 11:55, 4F
推
02/13 12:44, , 5F
02/13 12:44, 5F
→
02/13 12:45, , 6F
02/13 12:45, 6F
→
02/13 12:46, , 7F
02/13 12:46, 7F
推
02/13 13:00, , 8F
02/13 13:00, 8F
→
02/13 13:02, , 9F
02/13 13:02, 9F
推
02/13 13:07, , 10F
02/13 13:07, 10F
→
02/13 13:07, , 11F
02/13 13:07, 11F
java 近期熱門文章
PTT數位生活區 即時熱門文章