You are on page 1of 3

** Work In Progress **

Debugging Struts 1.0 Applications within VisualAge for Java 3.5


using Apache Tomcat Test Environment
1/19/01 John Brugge
1/29/01 Randy Bielby

These are notes to capture a set of steps that will allow you to configure your VAJ3.5 environment to debug
web applications written for the Struts 1.0 framework. This may not be the optimal steps, so any
improvements that people discover should be added to this. These may also change slightly as each of the
components goes through different versions.

These steps are modifications to the general steps layed out in a “Mini-HowTo” document submitted on the
web by Nikolaus Rumm. Read http://kephera.dhs.org/services/vaj_jonas_struts_howto.htm for a more
complete description.

Assumed environment:
• Windows NT 4 SP4
• VAJ 3.5 patch 2
• Tomcat Test Environment v?? (IBM hasn’t versioned this, but it seems to be Tomcat 3.1)
• Struts 1.0
[Note: Struts is not officially at a 1.0 release as of this writing, but the APIs are finalized and they are
ready to release very soon now.]
• JAXP 1.0 -compliant XML parser

Installation and Setup Procedure


Step 1: Install and setup Tomcat
1. Make sure that VAJ 3.5 patch 2 is installed (“Help | About VisualAge” should show “Version 3.5 IV3-
4 JDKWAS 1.2.2 Patch 2”)
2. With VAJ closed, run the Tomcat Test Environment setup (\\mdcor0nt\is\TRANS\Java\VAJ\Tomcat
test env\Setup.exe).
3. Launch VAJ and remove the Websphere Test Environment (File | Quick Start | Feature | Delete
Feature)
4. Add the ‘Apache_Tomcat_Test_Environment’ feature (File | Quick Start | Feature | Add Feature)

Step 2 : Update the XML parser in use


Struts 1.0 needs a JAXP 1.0-compliant XML parser for its Digester class (the class that reads the struts-
config.xml startup file). The following parsers can be used:
• IBM XML4J v3.1.1
• Apache Xerces-J v1.3.0
• Sun JAXP Reference Implementation v1.0

1. Unzip the files jaxp.jar from a JAXP-compliant parser distribution and put it in the Tomcat lib
directory (<VAJ>\ide\program_resources\Apache_Tomcat_Test_Environment\lib). This is a set of
interface classes that define the JAXP specification. You can remove the file xml.jar, which is an
earlier version of Sun’s parser.
2. Place the appropriate parser JAR file in the same lib directory. This will be something like xerces.jar,
xml4j.jar or parser.jar.
3. Import the jaxp.jar and parser JAR files into a new project in VAJ, called JAXP (or XML or whatever
you like.)Configure the JAXP interfaces to point to the parser implementation classes. This involves
defining two system properties. See the JAXP 1.0 Specification (Chapter 3, Pluggability Layer) for
more detail (http://java.sun.com/xml/jaxp-1_1-pfd-spec.pdf).

Page 1 of 3 Last Updated:


** Work In Progress **

To use the Sun parser, you'd define system properties

javax.xml.parsers.SAXParserFactory=com.sun.xml.parser.SAXParserFacto
ryImpl
javax.xml.parsers.DOMParserFactory=com.sun.xml.parser.DocumentBuilde
rFactoryImpl

To use the Xerces of IBM parser, you'd define

javax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserF
actoryImpl
javax.xml.parsers.DOMParserFactory=org.apache.xerces.jaxp.DocumentBu
ilderFactoryImpl

Step 3 : Import the Struts framework


1. Unzip the Struts distribution to your local drive.
2. Import the lib\struts.jar file into a new project called ‘Struts’, including .class and .resource files.
3. If you want the Struts source available in VAJ, import it from the Struts source distribution into the
Struts project. Be sure to still include the .resource files.
4. Deploy any of the Struts sample applications to Tomcat by copying their .war file to the
<VAJ>\ide\project_resources\Apache_Tomcat_Test_Environment\webapps directory. When Tomcat
runs it will see these, expand them into standard directories, and create a default context for them.
5. To debug any of the Struts sample applications, you’ll need to import the source into VAJ into the
Struts project. The sample source code is also in the Struts source distribution listed above.

Step 4: Configure the TomcatRunner application


To run Tomcat within VAJ, you run the application com.ibm.ivj.tomcat.TomcatRunner. The properties of
this application are critical to getting Struts applications to run within VAJ.
1. Open the Properties dialog for TomcatRunner, and select the Classpath tab.
2. Select the ‘Project Path’ check box, and ‘Edit’ and add the JAXP and Struts projects that you created
above.
3. Select the ‘Extra directories path’ check box, and ‘Edit’ and replace the line
.\lib\xml.jar;
with the lines
.\lib\jaxp.jar;
.\lib\parser.jar;
4. Add entries for each Struts application that’s been installed:
.\webapps\<app name>\;
.\webapps\<app name>\WEB-INF\classes\;

If you’re lucky, you should now be able to run the TomcatRunner application, set breakpoints in the Struts
code and step through code. If not, try restarting VAJ and running again. If it still won’t work and you’re
not sure the problem, consult me until there’s a better knowledge base of experience with this.

Alternate installation notes:


Author: Randy Bielby

Overview:
This alternate installation process was derived by the desire to isolate the VAJ projects and additional jar
files. The goal was to only have the classes appear once within VAJ. This was accomplished by importing
the Struts source and not the class files. This caused several issues because the source distribution was not
intended to be run as a webapp. Therefore several configuration files are missing from the source

Page 2 of 3 Last Updated:


** Work In Progress **
distribution. Thus, the need to copy tld's etc from the binary distribution into the classpath of
TomcatRunner. This method is not better or worse then the first description written above. I just wanted to
better understand how TomcatRunner treated is classpath and it's resource files (tld's etc). So ,this is what I
came up with.
• Steps 1 and 2 from above should be performed except that you don't necessarily need jaxp.jar and
parser.jar added to the lib directory. Do not proceed with steps 3 and 4
• Select the properties for com.ibm.ivj.tomcat.TomcatRunner and remove the xml.jar from the classpath.
Also, add the JAXP project that was added in step 2.
Step 3: Import the Struts framework
1. Import the source distribution of Struts. This will give you a directory structure within the VAJ
project_resources directory of this:
• <VAJ>\ide\project_resources\Struts\jakarta-struts\src - this will contain any resources for
both the framework and the example app
• <VAJ>\ide\project_resources\Struts\jakarta-struts\src\share - this will contain all the
Struts framework resources
• <VAJ>\ide\project_resources\Struts\jakarta-struts\src\example - this will contain any
resource for the example app
• <VAJ>\ide\project_resources\Struts\jakarta-struts\web\example - this has the web
resources for the example app. All jsp, html, xml, and tld documents should be here
2. Add the resource file struts-config_1_0.dtd from the Struts binary distribution. This file is contained in
the package org/apache/struts/resources and should be imported into the Struts project under the
directory structure jakarta-struts/src/share/ (see note above for what is contained within each directory
tree)
3. Add the resource files struts-bean.tld, struts-html.tld, struts-logic.tld to the WEB-INF directory for the
example app. These are contained within the binary distribution. You should also add the app.tld and
the struts.tld from the source distribution.
Step 4: Configure the TomcatRunner application
1. If you would like to run the Struts example app you will need to add a context entry to the Tomcat
server.xml file. It should look something like this:
<Context path="/struts-example" docBase="../Struts/jakarta-struts/web/example" debug="1"
reloadable="true"/>
Where path is the uri for the app, docBase is where the Struts example app resides within the
project_resources directory structure. In this case, Struts was imported into a project called Struts.
2. Also, to run the example app you will need to add 2 entries to the TomcatRunner classpath.
..\Struts\jakarta-struts\src\example\ and ..\Struts\jakarta-struts\src\share\. This will provide VAJ a
reference to the resources contained within each of these directories. The src/example for the example
app and the src/share for the Struts framework itself. Also, see 4.4 above for more info.

Page 3 of 3 Last Updated:

You might also like