9.2. Configuring and Loading the Primary Application Instance

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 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. For example, if you are using the IBM JDK RPMs, 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 such as:

      -rw-r--r--   1 auser  ccm-deve    2304 Jul  8 16:55 ant.properties
      -rw-r--r--   1 auser  ccm-deve   19698 Jul  8 16:57 build.xml
      -rw-r--r--   1 auser  ccm-deve   19698 Jul  8 16:57 ccm.classpath
      -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.

      TipTip
       

      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. Therefore, 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 in order to use the project environment you just created. Logged in 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 Example 9-1; the \ has been added for printing clarity:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <ccm:project name="myapp"
              prettyName="My Application"
              ccmVersion="6.1"
               xmlns:ccm="http://ccm.redhat.com/ccm-project"
     xsi:schemaLocation="http://ccm.redhat.com/ccm-project \
    file:///usr/share/ccm-tools/xsd/project.xsd"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
        <ccm:databases>
          <ccm:database name="oracle-se"/>
        </ccm:databases>
    
    <!-- List all project specific applications here -->
    <ccm:build>
    <ccm:application name="myapp"/>
    </ccm:build>
    
    <!-- List all shared, prebuilt applications here -->
    <ccm:prebuilt>
    <!--<ccm:application name="ccm-cms" version="6.1.0"/> -->
    </ccm:prebuilt>
    
    </ccm:project>

    Example 9-1. Stock project.xml file

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

    <ccm:prebuilt>
    <ccm:application name="ccm-cms" version="6.1.0"/>
    </ccm:prebuilt>

    NoteNote
     

    To pull in additional prebuilt applications, add them to the ccm:prebuilt section of the document.

  6. Once you have edited and saved the project.xml file, run ccm-configure 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. It also creates a new ccm.classpath, which is used by some of the build tools.

  7. Now you are ready to build the project. From the main directory (where project.xml is located), run ant deploy.

    ImportantImportant
     

    Depending on your environment, you may need to set or change your JAVA_HOME in order for ant to work properly. If you are using a version of ant that was compiled with gcj, then you will need to invoke classic-ant instead of ant.

    deploy is an Ant task; it directs Ant to compile the various Java source files in your application code, and deploy the application code into the appropriate webapp location.

At this point, follow the instructions specified in Section 6.2 Configuring and Loading the Primary Application Instance, with a couple of exceptions:

  1. CCM_HOME should already be set by the development environment scripts

  2. pkg-key values for custom applications will be found in the name attribute of the ccm:application element in the application's application.xml file.

  3. Servlet container config files are already generated by the ccm-devel-create.pl, so the resin/tomcat config generation step should not be repeated.