Bob Balaban's Blog


    Bob Balaban


    Want to debug Java agents INSIDE Designer? You can! (sort of)

    Bob Balaban  July 7 2010 02:20:00 PM
    Greetings, Geeks!

    Here's a little something I stumbled upon last night: (using Designer 8.51) a way to actually debug Java agents *without exiting Domino Designer*!

    I'm pretty sure this is not documented, or actually, even supposed to be possible. But, here's the scoop.

    First, this only works if your agent is also set up to be a Java "application", i.e.,it has to have a main() method in it. To see how to do that, visit my previous posts on the "2-headed beast" technique.

    Assuming you've done that, open up the agent (.java) file in Designer. A new menu choice appears in the top menu bar: "Run". Click on that, and select "Debug Configurations". You are now going to set up a debug configuration that tells Eclipse (hidden down below the layers of Designer) how to launch and debug your Java code. You'll want to right-click and select "New" to create a new configuration. You can name it (but in my experimentation, I've found that Designer rarely, if ever, saves these, so you'll have to create the configuration anew each time). See Figure 1 for a screenshot of the dialog that comes up. You want to tell Eclipse that you've got a "Java Application" (that's why you need to be using the 2-headed beast, so that your code is both a Java "main" application AND a Domino agent).

    Figure 1: Image:Want to debug Java agents INSIDE Designer? You can! (sort of)

    You want the "project" to be your current NSF/NTF. Once that's set, you should be able to click "Search" for the "Application" choice and see your Java class name there.  I like to use the "stop in main" checkbox, so that the debugger automatically breakpoints the main() method. But it's not required, you can just set breakpoints yourself, wherever you want by double-clicking in the left-side gutter.

    The first time I tried that, I got an error saying that the program was not compiled to contain line numbers for the debuggerer. If you get that too, just go to the Project menu, select Properties. Click on "Java compiler" in the left on the left side of the dialog box, and change the following options (see Figure 2):
      - Compiler level to 1.5
      - select the "include line numbers" checkbox
      - select the "add variable attributes" checkbox

    Figure 2: Image:Want to debug Java agents INSIDE Designer? You can! (sort of)

    Click "Apply" and "OK". When it asks if you want to rebuild the code, you do.  Designer will usually save these settings, though I've found it confusing - apparently "project properties" can apply to the .java file, OR to the entire agent, and the UI doesn't really make the distinction obvious. Or maybe I'm wrong and just confused....

    So, once that's all set up, you can click the "Debug" button in the configuration dialog, and it will launch your agent. You'll probably be prompted to switch to the "Debug perspective", which I do recommend. For some reason, at least in my workspace, the debug navigation smarticons don't appear (step in, step over, etc). But you can still right-click in the stack-trace panel and get all the choices, the most common of which have FunctionKey shortcuts (F6 for "step over", and so on). It's just like real debugging!!

    Except, well, I couldn't figure out how to debug into a scriptlib. If you have supporting code out on your hard disk, you can add the folder and/or files to the "source code path" in the debug configuration dialog, or even specify it on the fly the first time you elect to step-in to the code. But scriptlibs are in the NSF/NTF, not on disk per se, and i couldn't figure out how to reference them. Anyone know how to do that?? It's worth a classic Looseleaf t-shirt (available in all sizes S to XXL, except for XL) to me to know!

    One other thing I had to play around with: how to get back to the "normal" Designer UI from the Eclipse debuggerer. Here's how I did it:
       - Click on the Window menu
       - Select "Open Perspective", then "Other"
       - Find "Domino Designer" in the big list, double-click on that

    A few caveats:
      - I'm pretty sure this is unsupported functionality, so it may disappear in some future release
      - I'm pretty sure this is unsupported functionality, so it's not guaranteed to always work
      - It's fun to play with, but I think for heavy debuggering I'm still going to just use standalone Eclipse
    Enjoy! Geek ya later!

    (Need expert application development architecture/coding help? Contact me at: bbalaban,
    Follow me on Twitter @LooseleafLLC
    This article ┬ęCopyright 2010 by Looseleaf Software LLC, all rights reserved. You may link to this page, but may not copy without prior approval.