Debugging your ICN plugins (or ICM widgets)

Case Manager developers are expected to be multi disciplinary. e.g. they’re expected to be experienced ECM consultants, guru in solution design, expert in Filenet P8 configuration/development, and both Java EE as wel as Web expert.

The thing is, most of the developers only excel in one, and lack expert knowledge of another. In practice most will definately be able to create some java (or dojo), but more than once i’ve seen people get stuck on the debugging. So, in this article, i’ll share a few short lines on how to debug your widgets/plugins.

Debugging java-code that’s run on the server.

This part assumes the use of Websphere and Eclipse.

First of all, know that all your Case Manager Widget’s or Content Navigator plugin’s java-code runs on the server. The .ear files you’ve included within your widget.zip are installed as applications on the webserver; and the navigator plugins you’ve included are run from within the Navigator web-application -> that’s run on Websphere as well.

So following that your java code is run on Websphere there are two things we need to do to be able to debug.

1. Enable debug-mode in Websphere.

When enabling debug mode within Websphere, we bascially set enable debug mode in the Java Virtual machine. The easiest way to do this is by using the WAS console (https://<server>:9043/ibm/console)

Step 1. Login to the WAS console and locate your server (server1 in the below screenshot). Click on it.

debugging-screenshot-1

Step 2. In the screen that follows, locate  “Debugging Service”  under “Additional Properties”, click it.

debugging-screenshot-2

 

Step 3. Check the “Enable service at server startup” and enter a “JVM-debug port”. Can be be arbitrary as long as it’s not in use.

debugging-screenshot-3

Step 4. Reboot Websphere. The debugging port won’t be upon until after reboot.

2. Connect to the JVM debug port using Eclipse.

Step 1. Open the Debug Configurations screen.

debugging-screenshot-4

Step 2. Add a new “Remote Java Application”.

debugging-screenshot-5

Step 3. Choose the Project you want to debug and enter the your websphere IP as HOST, and port 7777 as port. Then press debug. The screen will close, and the debugger will connect.

debugging-screenshot-6

3. Set your breakpoints and debug.

Place your breakpoint, execute the corresponding functionality in your application and watch the debugger kick in.

debugging-screenshot-7

Debugging your widget’s javascript.

Debugging javascript is quite easy in modern browsers. Although IBM cleary notes it’s designing its products for use with FireFox and Internet Explorer, i personally prefer Chrome.

When in chrome, simply press the F12 key.  In the screen that opens (The Developer Tools) then search for the Sources tab. This tab will list all .js files loaded, including your plugin script.

debugging-screenshot-8

An easier way to locate your line of code, is by pressint CTRL+SHIFT+F, allowing you to search all code for a specific line as shown below.

debugging-screenshot-9

Once you’ve found your file, just click the line-numbers to place a breakpoint and you’re set!

Debugging your Script-adapter’s javascript.

The above doesn’t really count for script adapters. As the script written in the adapters is executed through eval() or runscript. There are two workarounds.

  1. Externalize your script in a .js and call it from the script adapter.
    No much explanation needed i guess 🙂
  2. Make use of the debugger; statement.
    The debugger statement will force to hold execution whenever the Developer Tools are open (all browsers supported). The below screenshots demonstrates a simple ScriptAdapter that pauses on the debugger statement.

Additionally, if you can also drag your script-adapter from the hidden part in the page-designer onto the page. This way your script adapter will (if checked) actively show the payloads received by your script adapter.

debugging-screenshot-10

 

3 thoughts on “Debugging your ICN plugins (or ICM widgets)

  1. Avond Ivo,

    Kan hier toch niet vertrekken alvorens even te melden dat het een leuke site is.
    Herkenbaar en leerrijk ;-).

    Ik zet met de klassieker der klassiekers in mijn maag. Hoe kan ik de CN mooi beschikbaar maken binnen een webportaal zonder user login ? …

  2. Bedankt Stef! Super bedankt voor je positieve comment!

    Wat betreft je vraag.. die is wat lastig te beantwoorden zonder context. In de basis dient uiteindelijk “ergens” gebruiker informatie vandaan te komen en zijn er zat technische oplossingen denkbaar. Typisch is single sign on de oplossing, maar gezien het vraag neem ik aan dat dit niet direct een optie is.

    Aannemende dat de gebruiker zich heeft moeten aanmelden bij het portal, zou je op zich het portaal in moeten kunnen zetten om je authenticatie te regelen op een betrouwbare manier. Het vergt echter wel dat je een klein beetje maatwerk plaatst op je portal(backend).

    Wedervraag eigenlijk om je een goed antwoord te kunnen geven: hoe ziet je ecosysteem er uit? Een specifieker een aantal: hoe meld de gebruiker zich aan op het portaal? Draait het portaal op dezelfde applicatieserver als ICN? Wat voor applicatieserver is het (websphere? Jboss?,…), en wat voor technologie is het portaal?

    Gezien de vragen is het beter te mailen, zie kopje CV voor mijn mail.

Leave a Reply to Ivo Jonker Cancel reply

Your email address will not be published. Required fields are marked *