Build Development Environment:

 JavaServer/Web Container Applications

This lesson is concerned with installing and configuring the software suite for building JavaServer/Web Container applications.  It is a stand-alone environment suitable for developing and testing Java Servlet-based applications that, when debugged, may be ported to a different production environment.  It further assumes that view and control components will use the JavaServer Faces framework.

The development suite includes the following software:

  1. Java Development Kit (JDK) 6.0, build 20
  2. Apache Tomcat JavaServer 6.0.28
  3. Eclipse Helios Java EE IDE for Web Developers
  4. MySQL Community DBMS Server 5.1.50
  5. JavaServer Faces Framework

These tools are quite sophisticated, enabling the developer to work at a higher level of abstraction and more productively than possible using a conventional compiler and editor.  But they are also very interdependent with respect to their respective versions. Consequently, a compatible set of resources, for Windows systems, has been gathered for Comp 426 course work.  Versions numbers are listed and a set of downloads is available from the course Tools page.

Whereas these systems may be installed in several different orders, the sequence listed above avoids several problems of dependency.  Most of these tools encourage you to install them in default locations on a Windows C drive.  It is quite likely that you will need to uninstall and reinstall some of them over the course of your work.  I strongly encourage you to create a set of high-level directories, on your D drive, where you can install these tools so that you can easily find them, separate them from system software, and, if necessary, uninstall and, possibly, delete them.  Consequently, I use the following directories:


Java Development and Runtime Environments

There are several versions of Java available; this lessons presumes Java 6.0, build 20.  Later builds are available, but there are reported incompatibilities between them and the JavaServer Faces framework.  Consequently, you are encouraged to use Java 6.0_20 at this time.  If you are running a 32-bit machine, you need to download that version, otherwise use the 64-bit version.

Java installs using an install shield.  The process is relatively straight forward, however, you are encouraged to use the custom option so that you may place the jdk and jre in different directories under your MySoftware directory.

After Java is installed, you may test it using a command prompt and the command, java -version.


Apache Tomcat JavaServer/Web Container

Tomcat is Apache's Java Server.  It is designed to run both as a special purpose Servlet engine to which an Apache HTTP server passes Servlet requests or as a standalone server that processes both HTTP and Servlet requests.  However, it is generally not quite as efficient as Apache for HTTP tasks.  It is the JavaServer of choice for this course, and you need to install a version of it on your development system.  You should debug your Servlets there and then move them to your course directory only when they are well-behaved.

Tomcat is normally configured to run as a stand-alone program or as a service.  Consequently, the configurations are defined globally with respect to the server.  However, as a test server being used for development work for this course, it will normally be run from within the Eclipse IDE.  Consequently, it will be configured from within Eclipse, as well.  For suggestions for configuring Tomcat as a general service, see the Tomcat Lesson.  The comments below describe configuring tomcat from within Eclipse Helios.  They presume tht Eclipse has been installed and configured to use Java 6 and the (newly) installed Tomcat server.

  1. Download and install Tomcat using the installation shield.  I suggest doing so within a MyServers/tomcat directory.

    [the steps that follow presume that you have already performed the basic Eclipse install, described below.]
     
  2. Create a new Server instance: new > other > Server > Server
     
  3. Under the new Server entry in the Servers project, change the port number from 8080 to 8888:
    • Open the server.xml file
    • Find the <Connector> tag that includes 8080 and change it to 8888.
       
  4. Enable the server's Invoker Servlet:
    • Open the web.xml file
    • Find the two commented out sections of xml that reference the Invoker and uncomment them
    • Open the context.xml file
    • Replace the "plain" Context tag with the following:
      <Context reloadable="true" privileged="true" >

Eclipse Helios IDE

The version of Eclipse described here is the Eclipse Java Enterprise Edition for Java EE Developers.  It includes the OpenSource Web Tools for J2EE applications as well as support for,Java Servlet.  The installation is straight forward, but requires several configuration steps afterwards.  Again, you are encouraged to install it in a MySoftware/eclipse directory.

Once installed, you need to point it toward a (previously installed) Java compiler and JavaServer.  To do so, complete the following steps:

  1. Drill down to Window > Preferences > Java > Compiler and select version 1.6
     
  2. Also set the runtime environment: Window > Preferences > Java > Installed JREs and browse to your (separate) jre directory
     
  3. Link to your Tomcat JavaServer for testing:   Window > Preferences > Server > Runtime Environments, add the tomcat server, and browse to its install directory
     
  4. Configure the server, as described above.

MySQL DBMS Server

MySQL was originally and independent open source project and was distributed free of charge.  It has always been viewed as a very efficient, albeit limited, DBMS, and has been the most widely used DBMS.  It was bought by Sun several years ago and since has been acquired by Oracle when they bought Sun.  Consequently, its future as freeware is not certain, but the Community Edition is still free and is the one described here.  The version described is 5.1.50; both 32- and 64-bit versions are available on the course tools page; and MySQL can, of course, be downloaded from the MySQL site.  Also available from the tools page are the MySQL connector files -- the drivers -- and a set of gui tools for building and administering MySQL databases and users.

To install and configure MySQL, do the following:

  1. Download and save the various files in the local environment and expand any top-level zip files.
     
  2. In Windows, the download is a MicroSoft installer.  Run it.  I suggest using the custom install option so that you may install it in a directory of your choice, such as a MyServers directory.  Other than location, accept the defaults or obvious choices for creating a development environment.
     
  3. After the install, per se, accept the option to configure MySQL.  Again, the choices are either the defaults or obvious, except when asked for a root password, provide a password that you can, and DO, remember.   You will need that as you further configure your DBMS.
     
  4. After installing and doing the initial configuration of MySQL, "install" the gui tools.  They are included in the "tools" directory of the mysql download directory.  You can install them by simply unzipping the file and noting the execute files -- specifically, the MySQLAdministrator and MySQLQueryBrowser files.  You may want to create shortcuts to them and place them in a conveneient location.
     
  5. Place a copy of the driver jar file in your Tomcat 6.0 lib directory.  This file is named mysql-connector-java-5.1.10-bin.jar.
     
  6. Once you have installed MySQL and have it running, most probably as a service, open the MySQL Administrator tool, open a connection to your installation of MySQL, and login as root.  Create a new user -- using  your linux  loginname -- and a new schema -- loginnameeb2c.  Finally, using the User Administration tab, select your new username, and assign all preiviledges to yourself for your new -eb2c schema.
     
  7. Open the MySQL QueryBrowser, connect to your MySQL using your username and password, and create a table under your new schema, e.g., user.

 


JavaServer Faces within Eclipse

JavaServer Faces is a framework the facilitates building model - view - controller Web applications in Java.  It appears to be replacing Struts, an older but similar framework, as the middleware of choice for JavaServer applications.  The version that is discussed here is JSF 1.2, the last release before the current 2.0 version.  A key distinction is that JavaServer Page (JSP) technology is the view technology in 1.2, whereas JSF2.0 uses as its default an alternative technology, Facelets, based on XML.  Since JSPs still seem to be the display technology of choice in the field as a whole, JSF 1.2 is chosen as the framework to be used here at this time.  JSF is assumed to be used within Eclipse and, hence, the main discussion addresses installing JSF 1.2 within Eclipse and running applications within tomcat from there.

  1. Read the tutorial included in Eclipse; specifically, see JavaServerFaces Tooling User Guide > Getting Started > JSF Basic Tutorial.  Follow those steps.  The basic install is done as part of the wizard sequence of creating a new JSF project.   A couple of  changes will be pointed out along the way.
     
  2. Download several sets of JAR files from the course's Tools > Comp426 > JavaServerFaces > Libs directory.  I suggest putting them into a MyLibs directory and keeping the three subdirectories -- jsf, jstl, and tomahawk -- intact.
     
  3. Create a new Dynamic Web Project and on the first page, under Configuration, select JavaServer Faces v.1.2 Project.
     
  4. Create and/or add User Libraries to your project.  The first time you do this, you will create the libraries; thereafter, you will simply add them.  You will use two of these libraries and the third one whenever you wish to have your page upload a file (e.g., and image).  You will define three libraries: JSF1.2, JSTL1.2, and Tomahawk.

    On the fourth page of the wizard, entitled JSF Capabilities, under Type: User Library, you will likely see an empty text box.  On the right, select the Download Libraries symbol, and then select the JSF 1.2 (Mojara JSF API Implementation . . . ) from Oracle.  That will load the JSF libraries into Eclipse.  Thereafter, you can select this library on this page, if it is not already selected. 

    Next, add the JSTL1.2 lib.  Select the Manage Libraries icon on the right, New, and name it JSTL1.2.  Then Add Jars, browse to your jstl folder, and select the two jar files there.  IndIndicate tht it is a System Library

    Do the same for a new Tomahawk library.
     
  5. For additional details, see the JavaServer Faces Lesson.