Working with Java Web Servers
This topic describes the configuration requirements and procedure for debugging Java web servers such as JBOSS and Apache Tomcat (both Server configuration and Windows Service configuration) in Enterprise Architect.
The procedure involves attaching to the process hosting the Java Virtual Machine from Enterprise Architect, as summarized below:
- Ensure binaries for the web server code to be debugged have been built with debug information.
- Launch the server with the Virtual Machine startup option described in this topic.
- Import source code into the Enterprise Architect Model, or synchronize existing code.
- Create or modify the Package Build Script to specify the Debug option for attaching to the process.
- Set breakpoints.
- Launch the client.
- Attach to the process from Enterprise Architect.
The configuration necessary for the web servers to interact with Enterprise Architect must address the following two essential points:
- Any VM to be debugged, created or hosted by the server must have the Sparx Systems Agent SSJavaProfiler75 command line option specified in the VM startup option (that is: -agentlib:SSJavaProfiler75)
- The CLASSPATH, however it is passed to the VM, must specify the root path to the package source files.
The Enterprise Architect debugger uses the java.class.path property in the VM being debugged, to locate the source file corresponding to a breakpoint occurring in a Class during execution. For example, a Class to be debugged is called:
This is located in physical directory:
So, for debugging to be successful, the CLASSPATH must contain the root path:
Using the Debug tab of the Build Script dialog, create a script for the code you have imported and specify the following:
- Select the Attach to process radio button, and in the field below type attach.
- In the Use Debugger field, click on the drop-down arrow and select Java.
All other fields are unimportant. The Directory field is normally used in the absence of any Class path property.
First ensure that the server is running, and that the server process has loaded the Sparx Systems Agent DLL SSJavaProfiler75.DLL (use Process Explorer or similar tools to prove this).
Launch the client and ensure the client executes. This must be done before attaching to the server process in Enterprise Architect.
After the client has been executed at least once, return to Enterprise Architect, open the source code you imported and set some breakpoints.
Click on the Run Debugger button in Enterprise Architect. The Attach To Process dialog displays.
Click on the OK button. A confirmation message displays in the Debug Output window, stating that the process has been attached.
The breakpoints should remain enabled (bright red). If the breakpoints fail, and contain either an exclamation mark or a question mark, then either the process is not hosting the SSJavaprofiler75 Agent or the binaries being executed by the server are not based on the source code. If so, check your configuration.