Building the Plants by WebSphere Sample using the Ant build tool



J2EE portability
Rebuilding the Samples that ship in this gallery
Getting started
Identifying the directory structure
Rebuilding and installing the Sample

J2EE portability

One of the great benefits of developing applications on a J2EE platform is portability.  All of the Sample programs in the Samples Gallery are developed on a workstation and run on z/OS and iSeries systems without changing one line of Java code.  By building J2EE applications on Intel or UNIX systems, a developer can eliminate the challenges of EBCDIC to ASCII or ASCII to EBCDIC file conversions.  The availability of tools makes it easy for developers to write and test on a development workstation and install the enterprise archive (EAR) files on z/OS and iSeries systems.

Rebuilding the Samples that ship in this gallery

Every WebSphere Application Server (Application Server) for z/OS and iSeries customer is entitled to the Application Server media for multiplatforms. If you install the WebSphere Application Server base product and the Samples on one of the platforms supported by this package you see the same gallery. The one exception is that when you click sample_name > Build with Ant > platform > Rebuilding and installing the sample.ear file, you get instructions to rebuild the EAR file on that platform.  Because text files in an EAR file (XML, xmi, JavaServer Pages (JSP) files, and so on) must be in an ASCII format, it is easier to edit those files on an ASCII machine.  If you make changes on an ASCII machine, you can then deploy and install the resulting EAR file on the z/OS or iSeries platform without an EBCDIC to ASCII conversion. 

Getting started

Install WebSphere Application Server on the distributed platform of your choice and indicate to install Application Server Sample applications as well.

Make a backup copy of the <profile_root>/samples  directory before attempting to modify or rebuild the Samples. Create a zip file of the samples directory. You can restore the samples directory to its original state by extracting the zip file.

Identifying the directory structure

The Samples are installed in the following directories:


<profile_root>/samples/src/PlantsByWebSphere Contains the Sample source code for the Plants by WebSphere Sample.
<profile_root>/samples/lib/PlantsByWebSphere Contains the Web archive (WAR) files, Java archive (JAR) files, and the final PlantsByWebSphere.ear file for the Plants by WebSphere Sample. This directory is created after the Plants by WebSphere Sample is rebuilt.
<profile_root>/samples/javadoc/PlantsByWebSphere Contains the Javadoc documentation. This directory is created after the Plants by WebSphere Sample is rebuilt.
<profile_root>/samples/bld/PlantsByWebSphere Contains the generated class files. Use these class files to generate the final PlantsByWebSphere.ear file. This directory is created after the Plants by WebSphere Sample is rebuilt.

Rebuilding and installing the Sample

The Plants by WebSphere Sample automatically installs with the WebSphere Application Server. You do not have to build the Plants by WebSphere Sample before using it. The following directions describe the steps to rebuild the Sample, along with additional information for modifications.


Executing the Sample build script
Transferring the rebuilt PlantsByWebSphere.ear file
Removing and reinstalling the PlantsByWebSphere.ear file

Executing the Sample build script

To rebuild this Sample, verify that profile_root/bin is in your PATH environment variable. Follow these steps to execute the Sample build script, which rebuilds the Sample:

  1. Open a command prompt.
  2. At the command line, change to the <profile_root>/samples/src/PlantsByWebSphere directory.
  3. Run the Sample build script:

  4. Type the following command:


    <profile_root>\samples\bin\PlantsByWebSphere\buildplantsby.bat


    • On Windows development platforms, type the following command:

      <profile_root>\samples\bin\PlantsByWebSphere\buildplantsby.bat


    • On UNIX and Linux development platforms, type the following command:

      . <profile_root>/samples/bin/PlantsByWebSphere/buildplantsby.sh

The Sample is now built.

The buildplantsby.bat and the buildplantsby.sh script in the profile_root/samples/bin/PlantsByWebSphere directory sets the appropriate class path information and executes the Ant build utility. Ant reads the build.xml files, which describe how to build the Sample. Refer to the Jakarta Web site for additional documentation on Ant.

Important Information  During the build process, only class files that have changes are rebuilt. The remaining class files are repackaged into the new EAR file.

Transferring the rebuilt PlantsByWebSphere.ear file

Use the File Transfer Protocol (FTP) to transfer the binary EAR file to the z/OS or iSeries server, using the following instructions.

  1. Find the rebuilt EAR file in the <profile_root>/samples/lib/PlantsByWebSphere directory
  2. Open an FTP session to the WebSphere Application Server for z/OS or iSeries from the development platform
  3. Change directory to <profile_root>/samples/lib/PlantsByWebSphere
    You may need to create the directory if it does not exist.
  4. If the PlantsByWebSphere.ear file exists, delete it so that the updated file can be written.
    del PlantsByWebSphere.ear
  5. bin
  6. put PlantsByWebSphere.ear
  7. quit

Removing and reinstalling the PlantsByWebSphere.ear file

By default, the Plants by WebSphere Sample installs into the profile_root/installedApps/<cell name> directory, where <cell name> is the name of the cell where your application is installed. Reinstall the Sample as described in the following steps:

  1. Stop the application server.
  2. Remove the Plants by WebSphere Sample EAR file:
    1. Type the following commands:

      cd <profile_root>\bin
      setupCmdLine

      cd <profile_root>/bin
      . ./setupCmdLine.sh

      On z/OS platforms:
      cd <profile_root>/bin
      . ./setupCmdLine.sh

      On iSeries platforms:
      cd <profile_root>/bin
      . ./setupCmdLine

      where <profile_root> represents the profile installation directory.
    2. Type the following command to uninstall the application (profile_root/bin must be in your PATH):

      wsadmin -conntype none -lang jython -c "AdminApp.uninstall('PlantsByWebSphere')" 

      wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('PlantsByWebSphere')" 

      On z/OS platforms:
      wsadmin.sh -conntype none -lang jython -c "AdminApp.uninstall('PlantsByWebSphere')" 

      On iSeries platforms:
      wsadmin -conntype none -lang jython -c "AdminApp.uninstall('PlantsByWebSphere')" 
  3. Reinstall the Plants by WebSphere Sample:
    • Change to the profile_root/samples/lib/PlantsByWebSphere directory.
    • Locate the PlantsByWebSphere.ear file.
    • Type the following command:

      wsadmin -conntype none -lang jython -c "AdminApp.install('PlantsByWebSphere.ear',
      	['-appname', 'PlantsByWebSphere', '-usedefaultbindings', '-node', '<node>', '-server', '<server>',
      	'-deployejb', '-deployejb.dbtype', 'DERBY_V10'] )"
      	    
      where <node> is the name of node, and <server> is the name of server on which to install the Sample.

      wsadmin.sh -conntype none -lang jython -c "AdminApp.install('PlantsByWebSphere.ear',
      	['-appname', 'PlantsByWebSphere', '-usedefaultbindings', '-node', '<node>', '-server', '<server>',
      	'-deployejb', '-deployejb.dbtype', 'DERBY_V10'] )"
      	    
      where <node> is the name of node, and <server> is the name of server on which to install the Sample.

      On z/OS platforms:
      wsadmin.sh -conntype none -lang jython -c "AdminApp.install('PlantsByWebSphere.ear',
      	['-appname', 'PlantsByWebSphere', '-usedefaultbindings', '-node', '<node>', '-server', '<server>',
      	'-deployejb', '-deployejb.dbtype', 'DERBY_V10'] )"
      	    

      On iSeries platforms:
      wsadmin -conntype none -lang jython -c "AdminApp.install('PlantsByWebSphere.ear',
      	['-appname', 'PlantsByWebSphere', '-usedefaultbindings', '-node', '<node>', '-server', '<server>',
      	'-deployejb', '-deployejb.dbtype', 'DERBY_V10'] )"
      	    
      where <node> is the name of node, and <server> is the name of server on which to install the Sample.
  4. Start the application server.

 

The rebuilt PlantsByWebsphere.ear file is now deployed to your Application Server.