7.2. Configuring the Development Environment

Once all of the packages have been installed, you must run a few scripts to add users and projects to your development environment.

NoteNote
 

On installation, the RPMs add several scripts to /etc/profile.d/ that set necessary environment variables for each user on login. Before taking the steps below, you should log out of any shell sessions you plan on using and log back in to get the correct variables set in your environment.

  1. As root, run /usr/sbin/ccm-devel-user.sh <username> to add a pre-existing user account to the development environment. This will create a set of directories belonging to the specified user that will serve as the basis for that user's development environment for all the various projects on the machine. When the script is finished, it will remind you to add the user to the ccm-devel group.

  2. Next, open a new shell as your development user (the user you just specified in the previous step). If you already have a shell open for your development user, close it and open a new one to source the new environment variables you just added. Set JAVA_HOME for your new shell: if you are using the IBM JDK RPMs specified above, the export JAVA_HOME=/opt/IBMJava2-131 command should complete this task for the bash shell.

  3. In your new shell, run ccm-devel-create.pl <project name> to create a new basic project. If you install the optional ccm-devel-cvs package, it will also import the empty application it creates into the CVS repository. When the script is finished, it will inform you of the HTTP port your new environment will serve pages from.

    To test to see if everything worked properly, do the following:

    • cd /var/ccm-devel/dev/username/project-name

    • ls -l

      You should see something like

      -rw-r--r--   1 auser  ccm-deve    2304 Jul  8 16:55 ant.properties.in
      -rw-r--r--   1 auser  ccm-deve   19698 Jul  8 16:57 build.xml
      -rw-r--r--   1 auser  ccm-deve      42 Jul  8 16:55 .cvsignore
      -rw-r--r--   1 auser  ccm-deve     586 Jul  8 16:57 project.xml
      drwxr-sr-x   9 auser  ccm-deve    4096 Jul  8 16:59 myapp

      where myapp is the name of the project you just created.

      NoteNote
       

      If you use the optional ccm-devel-cvs RPM, the first time you run ccm-devel-create.pl for a particular project, it will create all the directories for that project for the logged-in user and import an empty application into the CVS repository on that machine. Each subsequent time you run the script for different users, it will check the existing application out. So adding a developer to an existing project is no different than creating one from scratch.

  4. Set the environment variables and aliases you will need to use the environment for the project you just created. As the development user you just set up, run ccm-profile <project-name> to set these up. If you work on multiple projects in your environment, you will find yourself running this script frequently as you switch from project to project.

  5. Edit the stock project.xml file to import the project you are extending. The stock file looks like:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <ccm:project name="myapp"
    prettyName="My Application"
    type="project"
    versionFrom="myapp"
    xmlns:ccm="http://ccm.redhat.com/ccm-project">
    
    <!-- List all project specific applications here -->
    <ccm:build>
    <ccm:application name="myapp" prettyName="myapp" buildOrder="1"/>
    </ccm:build>
    
    <!-- List all shared, prebuilt applications here -->
    <ccm:prebuilt>
    <!--<ccm:application name="ccm-cms" version="6.0.0" buildOrder="1"/> -->
    </ccm:prebuilt>
    
    </ccm:project>

    This file is appropriate for a stand-alone project with no dependencies. Since you are extending existing WAF code, you need to add a reference to the project and version you are extending. To the opening ccm:project tag, add the attributes:

    extends="ccm-core"
    extendsVersion="6.0.0"

    Here, ccm-core refers to the name of the prebuilt project you installed with the ccm-core-devel-6.0.0-1 RPM, and 6.0.0 is the version number of that project.

    The <ccm:prebuilt> element may be changed like so:

    <ccm:prebuilt>
    <ccm:application name="ccm-cms" version="6.0.0" buildOrder="1"/>
    </ccm:prebuilt>

    NoteNote
     

    This system enables you to set up projects on one machine that extend different prebuilt projects or applications, and even different prebuilt versions of those projects or applications. See the File Layout section of this document to see where prebuilt projects and applications are installed. To pull in additional prebuilt applications that were built on the same project you are extending, add them to the ccm:prebuilt section of the document.

  6. Once you have edited and saved the project.xml file, run ccm-configure.sh from the same directory. This script transforms the project.xml file to create a new build.xml, which is the control file for the Ant compilation and deployment tool.

  7. Now you are ready to build the configuration files the system will actually run. From the main directory (where project.xml is located), run ant make-config. You should see something like:

    Buildfile: build.xml
    
    make-config:
    
    BUILD SUCCESSFUL
    Total time: 6 seconds

    make-config is an ant task; it directs ant to extract the configuration variables required by your project and add them to a new file in your main directory called config.vars.

  8. Next, open config.vars in an editor. The file will vary depending on the project you are extending, but it should look something like:

    # WAF initialization file
    admin-answer = 6
    admin-email = [email protected]
    admin-forename = Administrator
    admin-password = 123456
    admin-question = 12345
    admin-screen-name = Admin
    admin-surname = Account
    autoRegistration = true
    cache-expiry = 259200
    cache-properties = { "SiteNode.age=600", "SiteNode.size=100" }
    caching-active = yes
    db-pass = ccm_xyz
    db-pool = 10
    db-user = ccm
    debug-mode = false
    default-locale = en_US
    default-scheme = http
    developer-support = false
    dispatcher-context-path =
    dispatcher-servlet-path = /ccm
    dmi-active = false
    dmi-data-model-file = "/WEB-INF/sql/ccm-core/default/dmi/dmi-create.sql"
    dmi-xml-files = { "core-dmi.xml", "/WEB-INF/sql/ccm-core" }
    front-page = register/
    hostname = localhost
    hosts = { { "localhost", 8080 } }
    jdbc-url = jdbc:oracle:oci8:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = ora8) (SRVR = DEDICATED)))
    log-dir = /var/log/ccm-core
    log-level = warn
    log-size = 1000000
    login-stylesheet = login_en.xsl
    lucene-index-location = /var/www/ccm-core/lib/lucene-index
    permissionsDMLChecking = false
    primary-user-identifier = email
    rememberLoginByDefault = true
    search-intermedia-enabled = true
    search-lucene-enabled = false
    search-lucene-indexer-id = 0
    server-name = localhost
    server-port = 8080
    sitename = Red Hat WAF Demo
    smtp-host = localhost
    state-dir = /var/www/ccm-core/lib
    subsite-dispatcher-class = com.arsdigita.ui.login.SubsiteDispatcher
    workflow-send-alerts = false
    workflow-sender-email = [email protected]
    workflow-sender-given-name = Workflow
    workflow-sender-surname = Alerts
    xslt-engine = Saxon
    xslt-timeout = 60000

    You may leave many of these variables as they are. However, you will need to at least set the log-dir and state-dir to a directory that you have write access on. Also, you will need to se the database connection information correctly. See Chapter 5 WAF Configuration for details.

  9. Once you have saved your changes to config.vars, you can generate the actual init files for the system by running ant make-init. This will take your configuration variables and integrate them with the system configuration file, called enterprise.init and stored in the main directory. It is probably worth inspecting enterprise.init with an editor as a sanity check after this step.

7.2.1. Deploying Code and Loading the Database Schema

Even though you have not yet written any code, the server will start and run on just the prebuilt project code. You should start and test it before trying to code anything. From the main directory, run ant deploy. Ant should copy the precompiled files from the project to the webapp directory, which is set up parallel to your development directory. To check that everything worked OK:

You should see something like:

drwxr-sr-x    2 auser   ccm-deve     4096 Jul  8 17:17 conf
drwxr-sr-x    2 auser   ccm-deve     4096 Jul  8 17:12 logs
drwxr-sr-x    3 auser   ccm-deve     4096 Jul  8 17:01 webapps

Now, load the database schema. From the webroot (cdweb), do:

The data model loading process above will change depending on the prebuilt project you are using.

7.2.2. Starting the Server

Finally you are ready to start the server. At the shell, type ccm-start; this is another alias set up by ccm-profile that automatically starts a servlet container instance on your assigned port. If all goes well, in a minute or two you should be able to browse to your machine and port and get the login screen. If this does not happen after a couple of minutes, try the following:

Then, in your original shell, enter ccm-stop to stop the server, wait a few seconds, and enter ccm-start to start it again. The error logs should assist you in determining what is going wrong.