如何调试Java代理(双头beast方法)
从Notes/Domino版本7开始,我就使用了Bob Balaban的“双头野兽”中的原则(http://bobzblog.com/tuxedoguy.nsf/dx/the-2-headed-beast-debugging-domino-java-agents-with-eclipse)用于在Eclipse中编写可调试的Java代理!这很有魅力——唯一的一件事是我必须将Eclipse中的代码复制/粘贴到标准Notes代理 对于DominoDesigner的当前Eclipse版本(8.5.3FP2),我试图看看是否可以使用相同的设置在DominoDesigner中直接调试代理(如Java程序)。看起来我可以让代码运行,但是,我不能让它在任何断点处停止。我得到的信息是: 由于缺少行号属性,无法在dk.domain.AgentTemplate中安装断点。修改编译器选项以生成行号属性 我已尝试将调试配置设置为“主停止”。它似乎停止了。但是,如果我跳过,它会运行所有代码——我看不到我在代码中的位置,当然也看不到变量及其值 已选择Preferences-Java-Compiler中的“将行号属性添加到生成的类文件”选项。我还没有找到其他编译器选项来生成行号 我在Designer中使用Java1.5法规遵从性 有人能设置这个吗如何调试Java代理(双头beast方法),java,debugging,lotus-notes,lotus,agent,Java,Debugging,Lotus Notes,Lotus,Agent,从Notes/Domino版本7开始,我就使用了Bob Balaban的“双头野兽”中的原则(http://bobzblog.com/tuxedoguy.nsf/dx/the-2-headed-beast-debugging-domino-java-agents-with-eclipse)用于在Eclipse中编写可调试的Java代理!这很有魅力——唯一的一件事是我必须将Eclipse中的代码复制/粘贴到标准Notes代理 对于DominoDesigner的当前Eclipse版本(8.5.3FP
/约翰嗯,有时候你只需要解释一下你的问题就可以找到解决办法 为了彻底描述这个问题,我最终尝试使用JDK1.6编译器遵从性级别(在preferences-Java编译器下)。这确实奏效了 因此,使用如下结构构建代理,您可以直接在Domino Designer中调试Java代理:
package dk.dalsgaarddata;
import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.DocumentCollection;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.Session;
import dk.dalsgaarddata.debug.DebugAgentContext;
/* ------------------------------------------------------------------------------------
Created: 2009.04.21/Jda
Revised: 2009.04.29/Jda - v.1.1
Agent template....
------------------------------------------------------------------------------------ */
public class AgentTemplate extends AgentBase {
// DEBUG: For Eclipse debugging - see main method at the end of this class.
// Beginning of "ordinary" Lotus Notes/Domino Agent....
private Session mySession = null;
private AgentContext myContext = null;
private DD_BackendLog myLog = null;
private void cleanUp() {
try {
if (null != myLog)
myLog.end();
if (null != mySession)
mySession.recycle();
} catch (NotesException ne) {
System.err.println("Error cleaning up log and Session.");
}
}
// Lotus Notes/Domino entry point...
public void NotesMain() {
try {
if (mySession == null) {
mySession = getSession();
myContext = mySession.getAgentContext();
}
SessionContext.getInstance(mySession, myContext);
myLog = SessionContext.getLog();
System.out.println("NotesMain Started....");
// Your code goes here....
myLog.information(".... completed!");
} catch (NotesException ne) {
myLog.error("Agent ERROR: NotesException = " + ne.text);
myLog.writeStackTrace(ne);
} catch (Exception e) {
myLog.error("Agent ERROR: Exception = " + e.getMessage());
myLog.writeStackTrace(e);
} finally {
cleanUp();
}
}
/* Instructions for debugging!!
// TODO - adjust run configuration
You need to add VM arguments, e.g.:
-Dsun.boot.library.path="c:\\Lotus\\Notes;c:\\Lotus\\Notes\\jvm\\bin"
... and you need to add a PATH environment variable, e.g.:
PATH c:\Lotus\Notes
*/
// Remember to rename these constructors when duplicating this code to a new agent!!!
// ... if not handled by Eclipse when pasting a copy ;-)
public AgentTemplate() {
}
public AgentTemplate(Session s, AgentContext c) {
this.mySession = s;
this.myContext = c;
}
// Entry point for Java program (when running from Eclipse)
public static void main(String[] args) {
// By example from Bob Balaban "The two-headed beast". See more at:
// http://www.bobzblog.com/tuxedoguy.nsf/dx/DominoAgents-Eclipse_v2.pdf/$file/DominoAgents-Eclipse_v2.pdf
System.out.println("main Starting....");
Session s = null;
Database d = null;
DocumentCollection dc = null;
AgentContext ctx = null;
System.out.println("NotesThread.sinitThread()....");
NotesThread.sinitThread();
try {
System.out.println("createSession....");
s = NotesFactory.createSession();
System.out.println("set database....");
d = s.getDatabase(DebugAgentContext.ECLIPSE_SERVER, DebugAgentContext.ECLIPSE_DATABASE);
System.out.println("Database: " + d.getFileName() + " on " + d.getServer());
System.out.println("set debug context....");
ctx = new DebugAgentContext(s, d, dc);
// Create the agent object, invoke it on NotesMain(), the way Domino does
System.out.println("create agent object....");
AgentTemplate agent = new AgentTemplate(s, ctx);
System.out.println("call agent....");
agent.NotesMain();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (s != null)
s.recycle();
} catch (Exception x) {
}
NotesThread.stermThread();
}
} // end main - and Eclipse entry point
}
为了便于测试,我在代码中留下了“print”命令。显然,您将从实际模板中删除它们
另一件可能有助于实现此功能的事情是,我更改了配置参数的大小写,使其与磁盘上目录的大小写完全匹配
/John我对Notes/Domino Designer了解不多,但您可能想发布一些错误来帮助他人。@Disco3-同意,只是受够了,把它扔回了角落;-)然而,进行适当的测试实际上也最终找到了解决方案。谢谢你的“提醒”;-)如此真实——我经常找到问题的答案,但却开始向别人解释。