Excellent work!  Ted (and the rest of the struts team) -- is there any
chance we could get  a version of this posted to the Apache web site?

Kyle Brown
Executive Java Consultant
IBM WebSphere Services

[EMAIL PROTECTED] on 09/21/2001 10:10:33 AM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Struts and Websphere Test Environment 3.5.3




I wrote this "document" as I was setting up my environment. It may be of no
use at all and I know for a fact that some of the things stated in it are
wrong. Nevertheless, it worked for me and, if nothing else, there might be
an URL in here you haven't visitied.

Regards,
S. Bro

================================================================================================================


                    Using Struts with VisualAge for Java WTE 3.5.3

------------------------------------------------------------------------------------------------------------

DRAFT!
------------------------------------------------------------------------------------------------------------


This document is split up in two parts:

     Administrator's tasks.

          These tasks are related to the shared repository. They must be
carried out only
          once, by the administrator, at the start of the project.

     Team Developers' tasks.

          These tasks are related to the team developers' local
configurations and they must
          be performed once by each developer in order for him or her to be
able
          to test locally.


Throughout this document the article


http://www7.software.ibm.com/vad.nsf/Data/Document2558?OpenDocument&SubMast

will be referred to as "IBM's Struts article". It is recommended that you
read the
part of this article related to VAJ 3.5.3 before returning to this
document.

Note that although the approach used here deals with the latest
version of Struts, the 1.0 version, it will most probably work with all
versions. However,
for the version 1.0b the "hack" used in step 5 of the Administrator's task
is not nessecary.
.

Instructions for deploying Struts on WAS comes with the Struts binary
distribution
(struts-documentation.war). Last minute updates can be found in the struts
user archives or at

     http://jakarta-apache.org


All the paths used in this document are relative to the classpath unless
otherwise stated.

------------------------------------------------------------------------------------------------------------


The number of ways in which a Struts project can be set up is legion. For
simplicity's sake the
approach used here assumes that all the nessecary files are contained
within VAJ. A real-life
project would probably keep some of the files in Visual SourceSafe,
WebSphere Studio or some
such tool for making code drops easier.

------------------------------------------------------------------------------------------------------------



Administrator's tasks.



Prerequisites:

     All WTE features must be present in the workspace before continuing.
That is:
     "IBM WebSphere Test Environment" and dependencies (i.e. "IBM XML
Parser for Java", etc.)
     must already be in your workspace.


1.)  Install a JAXP compatible XML parser.

          Struts depends on the presence of a JAXP compatible parser.

          JAXP is part of the Apache Tomcat 3.2.2 binary distribution
          downloadable from:


http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.2/bin/

          Install JAXP 1.0.1 as per the instructions found in the IBM
Struts article.
          Follow the instructions closely or problems may occur with
Windows 2000.

          Remember to version both the packages you imported and the
packages of which you
          created opened editions!


2.)  Download and install Apache Struts.

          Download and unzip the latest (at the time of this writing: 1.0)
version of the
          Apache Struts source code from:


http://jakarta.apache.org/builds/jakarta-struts/release/v1.0/src/

          Create a new Struts project in the VAJ workspace (e.g.:
"ApacheStruts") and
          import the Struts source code into the new project.


3.)  Installing Struts resources.


          In the file system, using WinZip, open the file struts.jar which
comes with the
          Struts binary distribution at


http://jakarta.apache.org/builds/jakarta-struts/release/v1.0/)

          and extract the files:

               org\apache\struts\resources\struts-config_1_0.dtd
               org\apache\struts\resources\web-app_2_2.dtd
               org\apache\struts\resources\web-app_2_3.dtd

          These file must be added the above path to the ApacheStruts
project on the
          "Resources" tab in the VAJ workspace. In addition to these files
the tag library
          descriptors must also be present (*a). These files are also part
of the Struts
          binary distribution and must likewise be added to the resource
tab of the
          ApacheStruts project as:

               WEB-INF\app.tld
               WEB-INF\struts.tld
               WEB-INF\struts-bean.tld
               WEB-INF\struts-form.tld
               WEB-INF\struts-html.tld
               WEB-INF\struts-logic.tld
               WEB-INF\struts-template.tld



          *a:  Note that some of the tld files included with the Struts
distribution are
               deprecated and provided merely for backwards compatibility
(see
               http://jakarta-apache.org). The wise thing to do would
probably be to omit
               these files to avoid someone using them by accident or
convinience.



4.)  Create a Project for the Web Application.

          This project will contain derivatives of Struts classes as well
as any project specific
          code. The resource tab for this project will contain those Struts
configuration files that
          will have to be modified by team developers as work progresses.
So, if your project's name
          is "BLAH" create a new project called "BLAH". On the resource tab
for the new project
          add the following resource files:

               WEB-INF\web.xml
               WEB-INF\struts.config.xml
               ApplicationResources.properties (*b)


          Make sure team developers have write-access to these files.


          Finally, translate the "web.xml" file for the Struts project into
a
          "yourwebapp.webapp" file (Detailed reasons and instructions for
this
          can be found in IBM's Struts article.) and add this file to the
web
          project as (assuming your webapp's name is "BLAH"):

               blah.webapp


          *b   Note that the precise path of the
ApplicationResources.properties
               file can be configured through "web.xml" so it may differ
from
               project to project.


5.)  Resolving the WebSphere bug.

          Due to a "bug" in WebSphere (see:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=932)
          a small hack has to be made. In the method

               org.apache.struts.taglib.html.FormTag.doEndTag()

          change the lines:

               pageContext.removeAttribute(Constants.BEAN_KEY,
PageContext.REQUEST_SCOPE);
               pageContext.removeAttribute(Constants.FORM_KEY,
PageContext.REQUEST_SCOPE);


          to read:

               pageContext.getRequest
().removeAttribute(Constants.BEAN_KEY);
               pageContext.getRequest
().removeAttribute(Constants.FORM_KEY);


          These blocks of code are equivalent. One can easily assert that
this is indeed the
          case by using JUNIT:

               junit.framework.Assert.assertTrue("Expected bean attribute
got: null", pageContext.getRequest().getAttribute(Constants.BEAN_KEY) !=
null && pageContext.getAttribute(Constants.BEAN_KEY,
PageContext.REQUEST_SCOPE) != null);
               junit.framework.Assert.assertTrue("Expected form attribute
got: null", pageContext.getRequest().getAttribute(Constants.FORM_KEY) !=
null && pageContext.getAttribute(Constants.FORM_KEY,
PageContext.REQUEST_SCOPE) != null);

               pageContext.getRequest
().removeAttribute(Constants.BEAN_KEY);
               pageContext.getRequest
().removeAttribute(Constants.FORM_KEY);

               junit.framework.Assert.assertTrue("Bean attribute was not
removed", pageContext.getAttribute(Constants.BEAN_KEY,
PageContext.REQUEST_SCOPE) == null);
               junit.framework.Assert.assertTrue("Form attribute was not
removed", pageContext.getAttribute(Constants.FORM_KEY,
PageContext.REQUEST_SCOPE) == null);


          For more information about this bug and it's ramifications scan
the Struts user
          archives for the thread:

               "Form tag problem in VAJ 3.5.3 WTE with 1.0b2"



Team Developers' tasks.


1.)  Configuring the WebSphere Test Environment.

     Add a new webgroup to the WTE servlet engine configuration file, i.e.
edit the file:

          <VAJ Install Dir>\...\...\WebSphere Test
Environment\properties\default.servlet_engine

     and add a new webgroup. If your webapp's name will be "blah" the entry
would look like:

          <websphere-webgroup name="bah">
               <description>BLAH Web Application</description>
               <document-root>$approot$/web</document-root>
               <classpath>$approot$/web$psep
$$server_root$/../Blah</classpath>
               <root-uri>/blah</root-uri>
               <auto-reload enabled="true" polling-interval="3000"/>
               <shared-context>false</shared-context>
          </websphere-webgroup>

     Note that the classpath includes the web application specific project
resources ($server_root$/../Blah).
     This is were we will keep the blah.webapp file so all developers can
share the same file (see
     "Administrator Task 4"). I've had no luck in setting this particular
path with the WTE GUI as it seems the
     servlet engine loads the webapp file before setting the WTE classpath
(?!).

     Optionally, if you're not going to use it you can comment out the one
already present (i.e. default_app) to
     avoid cluttering up the WTE console trace.

     Next you need to manually create the neccesary folder for the new
webapp, ie:

          <VAJ Install Dir>\...\...\WebSphere Test
Environment\hosts\default_host\blah


     Finally, start the WTE and set the classpath. The classpath must
include the ApacheStruts project
     as well as the JAXP parser project and the web application specific
project ("BLAH" above). If
     you are using JUNIT and LOG4J these must be added to the classpath as
well.

     You should now be able to start the servlet engine and start using
Struts.


Resources:

     Jakarta homepage:

          http://jakarta-apache.org

     The official Struts user archives:

          http://www.mail-archive.com/struts-user@jakarta.apache.org/

     Other sites mirror these archives, e.g.:

          http://marc.theaimsgroup.com/?l=struts-user&r=1&w=2&b=200105


     Apache Struts and Visualage for Java:

http://www7.software.ibm.com/vad.nsf/Data/Document2557?OpenDocument&p=1&BCT=1




http://www7.software.ibm.com/vad.nsf/Data/Document2558?OpenDocument&SubMast


     General information about Struts:
          http://husted.com


TODO:
     Resolve the WebSphere bug by importing a newer version of Jasper. The
version needed is part of the
     Apache Tomcat 3.2.2 distribution. This is preferrable to changing the
Struts source code.

     What's the difference between WTE classpath and servlet engine
classpath?

     Use "The Struts Validator".

          http://home.earthlink.net/~dwinterfeldt/

          See the threads:
               "Any Success With Validator?"
               "Validation Clarified"



-------------------------------------------------------------------------
SBT  24/06-2001, 09/07-2001, 10/07-2001
-------------------------------------------------------------------------


Walking tour:

     http://husted.com/about/struts/example-tour.html#struts-config.xml
     D:\jakarta-struts-1.0-src\web\example

Detailed System Design, control-flow:

     http://www-106.ibm.com/developerworks/library/j-struts/?n-j-2151



-------------------------------------------------------------------------
Team development:
-------------------------------------------------------------------------
http://groups.google.com/groups?hl=da&safe=off&ic=1&th=55adb9df6c5583ed,8&seekm=3725CC57.4EB283A5%40trcinc.com#p


-------------------------------------------------------------------------

System Design:
     Which JSP tags are we using. Did we create any ourself?

================================================================================================================












                     "West, Tedie"         To:
[EMAIL PROTECTED]
                     <Tedie.West@eBr       cc:
                     eviate.com>           Subject:      Struts and
Websphere Test Environment 3.5.3

                     20-09-01 23:28
                     Please respond
                     to struts-user






Hi All,

Has anyone been able to get the Struts examples to run under the Websphere
Test Environment in VisualAge for Java v3.5.3?
Which configuration files need to be adjusted? What are the steps you took?
I am getting a HTTP error 503 when trying to run the examples?

I have been referencing an article that I found on the IBM website from
Kyle
Brown that tells the necessary steps. However, I
have been unsuccessful.

Thanks.
Bye.

Tedie West
Product Development
eBreviate
Office: 972-797-9262
[EMAIL PROTECTED]








Reply via email to