Deployment Checklist

You should read (and re-read) Brown, et.al., Chapters 6 and 23.  below is a checklist of the key steps invovled in deploying servlets and EJBs from the VisualAge environment to WebSphere.


Application Server Structure

Node
  Application Server
    EJB Container
      Session EJB 1
      Session EJB 2
      Entity EJB
        DataSources
    Servlet Engine
      Web Application
        Servlet 1
        Servlet 2

Create Deployed Files

  1. Create a separate jar file or deployed directory structure for each major layer of architecture
  2. From VAJ, select EJB, EJB group, or package and select export > deployed ejb
  3. On panel, check Select referenced types and resources to include WebSphere required stubs and imported objects.
  4. Designate the directory to which the jar file or directory is to be written
  5. For EJBs that are to be referenced, create a Client Jar that includes necessary interfaces for a servlet or other class to connect to them.

Preliminaries

  1. Check the WebSphere configuration file: WebSpherepAppServebin\admin.config
    1. ...DBDriver=COM.ibm.db2.jdbc.app.DB2Driver
    2. dbUrl=jdbc:db2.was
    3. dbUser=userid_of_someone_with_admin_privialeges
    4. dbPasswword=password_of_someone_with_admin_privialeges
  2. If you are using Java 1.2, stipulate that DB2 use java1.2: db2root \DB2\java12
  3. Check driver and set-up DB2Driver driver at the WebSphere Adm. Domain level, if necessary
  4. [BP]: Set-up directory structure for deployed files outside the WebSphere tree, with one directory per system layer; e.g., servlets, session beans, entity beans, etc.

WebSphere Node

  1. Set-up the WebSphere node classpath to include general resources; e.g., D:\MyServers\DB2\java\db2java.zip;

WebSphere Application Server

  1. From WebSphere top tools bar, start Create Application Server
  2. Select both EJB and Web Applications
  3. Enter name for server: e.g., AddressSys; and a prefix for your application to stdout and stderr files: e.g., address_stdout
  4. Select your node
  5. Accept name of EJB container: AddressSysContainer
  6. Select default_host as virtual host; on General tab, accept servlet engine name: e.g., AddressSysServletEngine
  7. Change Web App name to nameAppWebApp: e.g., AddressAppWebApp
  8. Specify /nameApp as Web application: e.g., /AddressApp
  9. On the Advanced tab, specify servlet path
  10. On last page of Wizard, uncheck Enable File Servlet and check Enabling Serving Servlets By Classname
  11. Settings:  Command line arguments:  -classpath D:\MyServers\WebSphereApps\Address\servlets;
    D:\MySoftware\java\xml\xalan-j_2_0_1\bin\xalan.jar;
    D:/MyServers/WebSphereApps/Address/beans_session/ejb_session.jar;
    D:\MyServers\WebSphereApps\Address\beans_entity\ejb_entity.jar;
    D:\MyServers\WebSphereApps\Address\beans_mappers\ejb_mappers.jar;

WebSphere Servlet engine

  1. Export your servlets and related classes to the servlets directory created, above; use the directory option when exporting from VisualAge.
  2. On the WebSphere console, go down to nameAppWebApp item and right-click to bring up menu and select Create>Servlet.
  3. Create the servlet:  add name, package name, and URL alias: e.g., AddressBook.
  4. Set the classpath for the servlets on the AddressAppWebApp > Advanced tab.  Include the servlets directory or jar file, depending on how you deployed it, plus an other jar files needed:  e.g., ejb_session_client.jar and xalan.jar.
  5. Start the servlet engine.
  6. Test, if servlets can be tested independent of EJBs:  http://localhost/your_specified_url:  e.g., http://localhost/AddressApp/AddressBook 
  7. Settings for servlet enjine:  Virtual Host:  default_host
    Web Application Web Path:  /AddressApp
    Document Root:  D:\MyServers\WebSphereApps\Address\web
    Classpath:  D:/MyServers/WebSphereApps/Address/servlets
    D:/MyServers/WebSphereApps/Address/beans_session/ejb_session_client.jar
    D:/MySoftware/java/xml/xalan-j_2_0_1/bin/xalan.jar

    Shared context:  false
  8. Settings for individual servlet:  Name:  AddressBook
    Servlet class name:  edu.jbs.address.servlets.AddressServlet
    Servlet web path:  default_host/AddressApp/AddressBook

Deploy EJBs

  1. Export your EJBs.  BP: create separate jar files for each layer of EJBs and mapper classes.  Be sure to create a client EJB for session interfaces, to be used by servlet or servlet engine classes.
  2. Place jar files in directory structure accessible by WebSphere; BP: in separate directories for each level of the architecture.
  3. Create a DataSource: From the Wizards tool (at the very top), choose Create Data Source, giving it a name, designating the DB2 database you set up when you installed that system,  and selecting an installed driver.
  4. Set the classpath for EJBs now, since it will be used by the system when you create EJBs in the next step.  Do so at the Application Server level:  AddressSys.  Note that you do so in the form of a -classpath parameter followed by the pats to you EJB jar files.
  5. Create a separate EJB from the EJBContainer right click menu: e.g., AddressSysContainer
  6. For  entity EJBs, you will need to add a datasource, using the DataSource tab on from the right panel after you have selected an entity bean.  Note that you have to select from a previously created datasource.

Observations and Gotchas

  1. The deployment process is not difficult but it is involved.  You should do it at least three or four times beginning with a simple hello-world servlet and progressing to a full front to back hello world application.  And then remove it and do it again several times.
  2. I have run into several unexpected results.  One of these include being able to access an application using the unqualified domain name (jbssrv-cs) but not the fully qualified one (jbssrv-cs.cs.unc.edu).  The problem lies with not specifying aliases for the default_host.  Locate default_host in the WebSphere console and select the Advanced tab.  There you can designate localhost, 127.0.0.1, abbreviated doman names, etc.
  3. Not being able to use package names longer than (approximately) 24 characters in WebSphere whereas they work fine in VisualAge.
    TThis problem seems to come and go, so I don't have a clear understanding of it.  Try using shorter package names. 
  4. When deploying, it is tempting to dump multiple copies of classes into several different jar files to be sure that they can be located.  For example, including databeans in both its own databean.jar file and in a interface_servlet.jar.  However, this can cause problems.  Jar files generated by Java 1.3 and later can be sealed, stipulating that all classes for a given package must come from the same jar file.  Thus, for example, if only some databean classes are included in the interface-servle.jar file whereas the whole set is included in the databean.jar file, those not included in the former may generate sealing violation.  You can tell if your jar file is sealed by looking in the manifest; if you see something like

    Name: edu/jbs/ooc/databeans/
    Sealed: True

    then your jar file is sealed.

    The solution is to not sprinkle classes around in various jar files but to include them in mutually exclusive ones.