作者u9423504 (缘投农夫)
看板java
标题[问题] 关於IBM lotus Notes的Exception补抓
时间Fri Feb 12 15:17:18 2016
各位前辈好:
小弟目前的专案有一个需求,那就是使用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://webptt.com/cn.aspx?n=bbs/java/M.1455261443.A.E27.html
1F:推 asship: 是否为多执行绪的问题呢? 发生错误的时候程式已经离开 02/13 11:53
2F:→ asship: try-catch区块 02/13 11:54
3F:→ asship: 以前也在notes写过JAVA,好久了,你看看原厂文件 02/13 11:55
4F:→ asship: 他有一些范例可以参考 02/13 11:55
5F:推 asship: 刚刚找了一下以前写的笔记,发信不需要继承notesthread 02/13 12:44
6F:→ asship: 如果你需要等做完之後得到结果,可以用ExecutorService 02/13 12:45
7F:→ asship: 不太确定你为什麽开了一个执行绪之後就丢回应成功 02/13 12:46
8F:推 asship: 如果你有一定要继承NotesThread的理由 02/13 13:00
11F:→ asship: 上面这个连结你再参考一下 02/13 13:07