MicroStrategy ONE

Debugging Java Code used in a J2EE Environment

This topic illustrates how to use Eclipse to debug custom Java classes used with MicroStrategy Web. In the instructions below, the Apache Tomcat installation directory is assumed to be C:\Tomcat, simply for the sake of providing an example. Similarly, Eclipse SDK 3.2 is the version that is referenced throughout the instructions for illustrative purposes, but it is recommended that you install the latest version of Eclipse.

For your convenience, the instructions below provide some general guidelines in instances where they may facilitate the installation and configuration process. However, depending on the version of Eclipse that you install, these guidelines may or may not be precisely the same as those provided by Eclipse. The Eclipse Web site provides the most current instructions.

After the Web Customization Editor is successfully deployed,  it creates a project called Web_Mstr. You need to add the Tomcat plugin so that you can start and stop Tomcat from within Eclipse.

  1. Search for and download the version of the Sysdeo Tomcat plugin that works with your version of Eclipse. (For example, go to a site such as http://www.eclipsetotale.com/tomcatPlugin.html.)

  2. Open the zip file and extract the files it contains into the eclipse\plugins folder.

  3. Go to the eclipse\plugins folder and locate the folder where the new plugin was installed  (com.sysdeo.eclipse.tomcat_3.x).  

  4. Open this folder.

  5. Unzip DevLoader.zip and extract the files it contains into the C:\Tomcat\server\classes folder. This will install DevLoader.

    If you want to use DevLoader with Tomcat 6.x. RenameDevLoader.zip to DevLoader.jarand put it in <%Tomcat6_Home%>/lib.

  6. Close Eclipse and reopen it so that the new plugin is loaded.

  7. Right-click your  project on the Package Explorer tab and select Properties. The Properties window opens.

  8. In the left-hand pane, select Tomcat.  

  9. In the right-hand pane, select the General tab and:  

    1. Select the Is a Tomcat Project check box.

    2. Type /MicroStrategy (or the name of your WAR file) in the Context name text field.

    3. Clear the Mark this context as reloadable (reloadable="true") check box.

    4. Select the Redirect context logger to Eclipse console check.

  10. With Tomcat still selected in the left-hand pane, select the DevLoader Classpath tab in the right-hand pane and select the Activate DevLoader check box. 

  11. Click OK

  12. The Tomcat Plugin uses the default JRE to launch Tomcat.  (It is a Tomcat prerequisite that this JRE must be a JDK.) To set the default JRE for Eclipse, open the Window menu and select Preferences -> Java -> Installed JREs. Browse to the JDK.

  13. To activate Tomcat Plugin for Eclipse 3.x, open the Window menu and select Customize Perspective... -> Commands and check Tomcat in Available command groups.

  14. From the main window, select Window -> Preferences. On the left panel of the Preferences window:

    1. Select Tomcat. On the right panel:

      1. Select Version 5.x as the Tomcat Version selection.

        Note: 5.0.28 is arbitrarily assumed to be the Tomcat version that is installed, simply for the sake of providing an example. Depending upon the actual version of Tomcat that you installed, you might need to make a different selection here.

      2. Select a Tomcat home by browsing to the C:\Tomcat folder.

        Note: The Apache Tomcat installation directory is assumed to beC:\Tomcat, simply for the sake of providing an example. Depending upon the actual location where Tomcat is installed, you might need to make a different selection here.

    2. Select Tomcat>JVM Settings. On the right panel:

      1. Click the Add button to the right of the Append to JVM Parameters pane.

      2. Enter -Xmx256M in the text field on the New Tomcat JVM Parameter dialog and click OK.

      3. The value -Xmx256M is now displayed in the Append to JVM Parameters pane. Click OK.

      This sets the JVM Heap size for the Sysdeo plug-in to 256 MB to prevent out of memory errors.

Using Eclipse to Add Custom Classes

At this point, you should be able to start Apache Tomcat from Eclipse 3.2 and execute MicroStrategy Web. You can use the Tomcat menu options or toolbar icons to start, stop and restart Apache Tomcat. You should be able to add custom classes on the src (inside Web_Mstr) folder and debug custom code from Eclipse.

  1. You can add a new Java file (class, interface,etc) by using wizards from the Web Customization Editor. In cases, where you need to create and compile Java files outside of the Web Customization Editor, you can right-click the Web_Mstr project and select the appropriate option to create a new class, interface, etc. 

  2. Right-click on the Web_Mstr project and select Properties from the context menu. 

  3. Select Tomcat in the left-hand pane.

  4. On the DevLoader Classpath tab, select /Web_Mstr/plugins/pluginName/WEB-INF/classes and click Apply

  5. Click OK

  6. Close Eclipse and reopen it so the new settings will take effect. 

  7. Right-click Web_Mstr and select Tomcat project -> Update context definition. When you get a message saying that the operation was successful, click OK.

Using Eclipse to Debug Custom Code

With these changes, you should be able to add breakpoints to your custom code and debug it simply by starting Tomcat. DevLoader will allow you to recompile your code and have the changes applied automatically without having to restart Tomcat.