Tomcat

This topic describes how to set up and use a Tomcat server with the Workshop family of products. The topics discussed here are:

This topic assumes that you already have a server installed locally on your development machine, or on a server available for development. For information on installing, setting up and managing the server, consult the Tomcat documentation.

Defining the Server Inside the IDE

To define a server:

  1. Before you run an application for the first time, the Run > Debug command allows you to define your server.
  2. To define a new server, right click on J2EE Server and choose New.
  3. On the next screen, first specify a name for the server in the Name field. This name is for internal use in the IDE only.

  4. Next, click New to specify the server type.
  5. Choose the server by expanding Apache and choosing the appropriate server. Click Next to continue.

  6. In the next dialog, you must specify the Tomcat settings.

    Note that you must specify the full JDK (not just the JRE that is the default).

  7. Fill in the appropriate values and click Finish to continue.

  8. You will be returned to the Debug dialog. Click (beside the Deployed Projects box) to specify which projects will be deployed to this server.

  9. After you click Finish, the projects will be listed in the Deployed Projects box.

    Note that the first project is automatically selected in the Select Project to Debug field. You can use the pull-down to specify which project will be debugged.

    Only one project at a time can be debugged on the server. The project that is currently allowed to run in debug mode is the project displayed in the Select Project to Debug field. You are not required to run this project in debug mode, but if you wish to debug another project on the server, you must change this setting before debugging the application.

  10. Note the Connection Type default setting is for local servers that are managed within the IDE. Click Apply and the server definition is complete. A new server entry appears in Servers view.
  11. If you wish to debug your application at this point, click Debug to run the selected application in debug mode. Otherwise, click Close.

     

Updating the Server Definition

To update the definition for a server:

  1. Double click on the server name in the Servers view to see the Server Overview.

    From Server Overview you can view and set deployment and runtime properties.

    Note the Run module directly from the workspace option. This is a WTP feature that normally allows you to run your application in "exploded" mode where the application runs directly from your workspace. For Tomcat, WTP never creates a WAR file for deployment. Checking Run modules directly from the workspace means that Workshop will keep a copy of the Tomcat config in the workspace, while un-checking this option means that Workshop will modify the "master" config in the Tomcat installation.

    Click here for information on manual deployment.

    If you select Enable security the Tomcat server will run as an HTTPS server (not the default HTTP), but only if you have un-commented the <connector> element (<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->) in the server.xml file.

    The Enable Tomcat debug mode checkbox is ignored by Workshop.

Hot Deployment

Workshop supports hot deployment of JSPs and other artifacts like Struts actions.

If you update a JSP, changes are automatically published to the server and you can simply click the Refresh button to see them running live on the server. Other changes are automatically deployed and the application is restarted as necessary.

Accessing Artifacts Outside the Project

For Tomcat servers, Workshop integrates Sysdeo DevLoader which allows web project to use libraries/classes either from dependent projects or from external location (i.e. outside of project's WEB-INF/classes or WEB-INF/lib folder). Workshop detects the external references and does the following:

Note that Sysdeo DevLoader works in both exploded (the Run modules directly from the workspace option on the Server Overview) and WAR deployment.

Deploying Applications Manually

Manual deployment is not supported on Tomcat servers.

Using Remote Debugging

To debug on a remote server (or on a local server which is started and managed OUTSIDE of the IDE), you must configure the server for remote debugging, deploy the application manually and then define the remote server's address.

Step 1: Configuring the Server to Allow Remote Debugging

Configuring the server for remote debugging is a feature of the server. This information is provided for your convenience. For definitive documentation, consult your server documentation.

Tomcat 4.x -5.0

For Tomcat 4.1.x, the IDE uses standard JPDA and self-generated line maps.

For Tomcat 5.x, the IDE uses standard JPDA and self-generated line maps. The JSR-45 debug information has to be disabled by placing the following servlet in the application web.xml file:

<servlet>
        <servlet-name>nitrox-debugger-tomcat5</servlet-name>    <description>Added to compile JSPs without JSR-045 debug info</description>    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>    <init-param>        <param-name>suppressSmap</param-name>        <param-value>true</param-value>    </init-param>    <load-on-startup>3</load-on-startup></servlet>
<servlet-mapping>    <servlet-name>nitrox-debugger-tomcat5</servlet-name>    <url-pattern>*.jsp</url-pattern></servlet-mapping>

Open \Tomcat 5.0\bin\catalina.bat (or \Tomcat 4.x\bin\catalina.bat) on Windows or the equivalent shell script on Unix and define environment variable at the start of the BAT file:

    
  set JPDA_TRANSPORT=dt_socket  
  set JPDA_ADDRESS=8453
  

Start the Tomcat server using following command:

  catalina.bat jpda start

The Tomcat Server console should display this message:

  Listening for transport dt_socket at address: 8453

Tomcat 5.5

Tomcat 5.5 no longer ships catalina.bat on Windows platform. You can reuse the batch files from the Tomcat 5.0 release by copying over catalina.bat, setclasspath.bat . A Windows application called tomcat5w.exe shipped in Tomcat 5.5 is supposed to provide users a GUI to customize the Tomcat Server startup parameters. But in our test, adding the following in the tab Java > Java Options

    -Xrunjdwp:transport=dt_socket,address=8453,server=y,suspend=n

to enable remote debug did not seem to work.

Step 2: Preparing the Application for Remote Debugging

Before attempting to debug an application on a remote server, you must:

  1. Build the application (not required if Build Automatically is set).
  2. Deploy the application manually. You can deploy as an exploded application or use a WAR or EAR file to deploy.
  3. Clear, the work/temp directory to remove files without debug information.
  4. Make sure the deployed application version matches with the one in IDE.

Step 3: (Optional) Enabling JSP Servlet Source Debugging on Separate Server

When remote debugging an application on a physically separate machine, the debugger will hit JSP breakpoints but the IDE will not show the correct source line in JSP, becasue Workshop is trying to locate JSP servlet source for line mapping but the files are not available to the IDE.

To enable source debugging of servlets on a separate server, map the following directory (on the remote server) to a local directory, and use the Source Lookup Path dialog, or the Source tab in the Launch Configuration dialog (the Run > Run command), to add the mapped directory to Source Lookup Path.

For Tomcat, all versions, map the directory
$CATALINA_BASE\work\Catalina\localhost\_
e.g:
C:\Tomcat 5.0\work\Catalina\localhost\_

Step 4: Defining the Remote Server and Debugging the Application

To define a remote server:

  1. Define the server.
  2. Click Run > Debug to modify the server definition for remote operation. Click on the name of your server under J2EE Server.

    Change the Connection Type to Standard (Socket Attach) and specify the Host and Port.

  3. The Allow termination of remote VM checkbox is not recommended because it allows the IDE to do a hard stop of the server, even if the server is in mid-transaction.
  4. Click Apply to save your changes. (The screen shot below demonstrates a "remote" server that is actually installed locally but managed outside the IDE.)

  5. Click Debug to run the application in debug mode.

Note that when debugging an application on a remote server, you must not disable the Run module directly from the workspace option when you update server settings.

Troubleshooting

Breakpoints Not Hit on Tomcat 5.5 (Linux Only)

When debugging with Tomcat 5.5 on Linux operating systems you may receive the error message:

    JSR45 debug information must be disabled so that the breakpoints and line stepping work properly.
    Please set the suppressSmap property in web.xml to true and restart the debugger.

This message occurs when JSR45 is not disabled in the first run before the JSP servlet is compiled.

To resolve the problem for subsequent runs, touch a JSP in the application in order to force a recompile.


Still need help? Post a question on the Workshop newsgroup.