Tag Archives: debug

Debug Java From Lotus Notes Designer

We do not prefer to write agents in Java just because we are not able to debug the Java agent in Lotus Notes Designer. As we think Designer do not have any debugger for Java, but let me clarify that Lotus Notes Designer 8.5.x (also known as Domino Designer in Eclipse) has in-built Java debugger.

It is very clear that to write a Java agent we must extend AgentBase class and implement notesmain() function. So if our Java agent requires Domino Infrastructure to execute then how can we debug it? We have to make it a Java application to debug it. So we must define main function in our Java agent.

I am assuming the name of the agent class is MyAgent.

 
[java]
protected Session _goSession;
protected AgentContext _goCtx;

public MyAgent(){}

public MyAgent(Session s, AgentContext c) {
_goSession = s;
_goCtx = c;
}

public static void main(String[] args) {
Session s = null;

NotesThread.sinitThread();

try {
s = NotesFactory.createSession();
// NotesMain(), the way Domino does
MyAgent a = new MyAgent(s, s.getAgentContext());

a.NotesMain();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (s != null) s.recycle();
} catch (Exception x) {}
NotesThread.stermThread();
}
} // end main

[/java]

After adding above code to your Java agent switch to Java Debugger Perspective and goto Debug Configuration and double click on Java Application in left side. Check stop in main option and click on debug button to start debugging.

I hope this helps you in debugging your Java agent. If any query feel free to write me back…:)