Debugging Java API code

You can use the following methods to debug your Java™ API code. With the IBM® Product Master Java API, these debugging methods are possible only for web-service-deployed Java API code and extension point Java API code.

Procedure

Debug your Java API code by using one of the following options:
Option Description
Print statements Print statements are sent to the log file of the application server where the product and its web services are running.
System.out.println("Search routine completed successfully.");
      		System.err.println("Could not contact database.");
Assertions
      {
        Item returnedItem = cat.getItemByPrimaryKey(itemPk);
        assert(returnedItem!=null);
      }
      catch (AssertionError e)
      {
        System.err.println("Assertion failed. "+e);
      }
Java API log file All PIMExceptions are logged to the logs/appsvr_yourWPCservername directory in your Product Master server installation directory.
User interface for Java IDE debugger support If you are using an IDE with remote debugging capability, such as RSA (Rational® Software Architect), you can use your source Product Master Java API project (the project that contains the Java API interface) to step through or "breakpoint" the code in your web service when it runs (and examines variables).
  1. Log in to the admin console of WebSphere Application Server.
  2. Locate the Product Master Enterprise Application, and go to the Debugging Service.
  3. Enter a debug port, for example, 7777 in the Debugging screen.
  4. Load the RSA project that you used to develop the Java API application (the one that you imported the ccd_javaapi2.jar file to).
  5. Create a debug configuration as Remote Java Application within your IDE project for the port number that you chose in WebSphere® Application Server. If necessary, change localhost to the IP address of your Product Master server.
  6. Set an appropriate breakpoint in your code.
  7. Start your debug profile in RSA.
  8. Start your web service through the URL method or your Java client.
Extension points code You can use your extension point code to debug your Java API code.
  1. Start Product Master in debug mode. For example, $TOP/bin/go/start_local.sh --debug.
  2. Create a Java project with your extension point source files.
  3. Go to the Debug Configurations dialog box and create a new remote Java application debug configuration with an appropriate name. Provide the following values in the appropriate fields:
    1. In the Connect tab, select your extension points implementation project as the project.
    2. Select Standard (Socket Attach) for the Connection Type.
    3. For the Host field, enter the hostname or IP address.
    4. In the Port field, specify the port that the service is running on. The type of port the service is running on depends on the type of extension point that you are trying to debug. For example, the import extension points are run as part of the scheduler; therefore, the port number should be the port on which the scheduler is running. The run value rule function is run as part of the application server, so the port number should be the one associated with the application server. You can create different debug configurations for different extension points as needed.
    5. Click Apply to save the new configuration.
    6. Place a breakpoint in your extension point source code and start the debugger.
    7. Start the extension point.