Dashboard > RIFE > ... > Installation > Examples with PostgreSQL and Tomcat
RIFE Log In | Sign Up   View a printable version of the current page.
Examples with PostgreSQL and Tomcat


Added by Geert Bevin, last edited by F.Baube on Dec 19, 2005  (view change)
Labels: 
(None)

Here are some notes on getting the RIFE DB demo "05_friends_basic" up and running quickly - on Debian Linux, using PostgreSQL 7.x and Apache Jakarta Tomcat version 5 - without having to dig too deeply into DB issues. Then you can jump straight into RIFE while putting off the DB "nuts 'n bolts". So if you have never had to set up a DB before, read on.

If you want a really "quick start", you might instead check the page [Easy DB setup with Apache Derby].

I post this because getting the Friends demo to run with PostgreSQL took a great deal of trial and error. I encountered many problems with ownerships and permissions in the DB's. After several tries, I found I had to set up everything in the simplest possible way that would work.
(I invite others to add to this page some ways to relax some of the restrictions I use here. Possibilities: using MySQL, or Apache Derby, or using another servlet container, or doing things differently (i.e. more flexibly) w.r.t. setting up users.)

Database

I won't write about how to get your DB installed and running. But in my experience, it is simpler on Debian stable than on RedHat, and AFAIK the default security settings for PostgreSQL on Debian are acceptable.

I tried MySQL first and encountered many problems. Setting up access was fairly fubar. PostgreSQL went comparatively smoothly.

So, let us assume that your PostgreSQL DB is installed and running. There should be an O/S user named "postgres" who has full privileges w.r.t. the DB.
To verify:

yourname@localhost> grep postgres /etc/passwd

The PostgreSQL DB daemon should be up and running. To verify:

yourname@localhost> ps -A | grep postmaster

(You will get more than one match.)

Both MySQL and PostgreSQL say that the DB keeps a list of users & passwords that is different from the one kept by the operating system. This is true, but it complicates matters greatly. The interactions are complex, and figuring them out is inappropriate for someone whose primary interest is getting the RIFE demos up and running.

Important security note: when you run DB administration commands, never enter a password at the O/S command line; always use the command option that provides an interactive password prompt. This is so that passwords do not show up in a "ps" listing.

Other

For the servlet container I have used Apache Jakarta Tomcat 5.0.28 and 5.5.12.

When RIFE fails to connect to the DB, or has some other problems that throw an Exception, the messages that appear in the browser are not always helpful, particularly for DB neophytes. Some sort of brief "DB mini how-to" or "RIFE error message reference" might be in order here.

When you try to write your own RIFE DB app, make sure that you get the JDBC drivers. Copy them into your own project's WEB-INF/lib/ directory from $TOMCAT_HOME/webapps/04_friends_basic/WEB-INF/lib/

Procedure

Basically there are three steps:

  1. Establish the O/S user and DB user used by RIFE
  2. Create the DB used by RIFE
  3. Initialize this DB

Step 1 was by far the hardest to get right. After much experimentation, I found that the only setup that worked was to settle on one user name, and to use it in the operating system and the DB. This same single user name is used for all of the following:

  • the O/S user that owns the Tomcat installation
  • the O/S user that starts up Tomcat
  • the DB user that creates the DB table "rife"
  • the user that is specified in the RIFE configuration file rep/config.xml

So, in "short" form the combined procedure for all three steps listed above (for PostgreSQL on Linux) is as follows:

  1. decide upon the name of the user; this could be a new user or an existing user; let's call it "rifeguy"

  2. if "rifeguy" is a new user, i.e. new to the O/S, then as superuser/root, do
    root@localhost> adduser rifeguy
    

    (for the prompts, AFAIK the defaults are fine)

  3. if Tomcat is installed but not owned by this user, then as superuser/root go to $TOMCAT_HOME and do
    root@localhost> chown -R rifeguy *
    root@localhost> chgrp -R {rifeguy's group} *
    


  4. now log in as O/S user "postgres" (either by logging in explicitly, or via the "su" command)

  5. here's the lame part - where I avoid complex DB permission problems by using the same user name for the DB. Make this new user "rifeguy" known to the DB. do
    # run program supplied by PostgreSQL
    postgres@localhost> createuser --createdb --no-adduser --pwprompt rifeguy
    

    (and when prompted, supply the new password for user "rifeguy"; let's say that it is "rifeguyspa55word")

    IMPORTANT note: this password does NOT (and should NOT) be the same as the O/S login password for the user !

  6. now log in as O/S user "rifeguy" (either by logging in explicitly, or via the "su" command)

  7. now create the DB. do
    # run program supplied by PostgreSQL
    rifeguy@localhost> createdb rife
    


  8. modify your DB-related RIFE files:

    $TOMCAT_HOME/webapps/04_friends_basic/WEB-INF/classes/rep/config.xml:

    - make sure that the '<param name="DATASOURCE">' element specifies "postgresql" rather than "mysql"

    $TOMCAT_HOME/webapps/04_friends_basic/WEB-INF/classes/rep/datasource.xml:

    - optionally remove or <!- comment out -> the MySQL <datasource> element
    <!-- datasource name="mysql"> ... </datasource -->
    
    • modify the "user" element:
      <user>rifeguy</user>
      
    • modify the "password" element:
      <password>rifeguyspa55word</password>
      
  9. start up Tomcat. Note that it maye have needed some finagling if you installed RIFE to run alongside your pre-existing Tomcat apps.

  10. now you must use the RIFE app to initialize the DB table. Point your browser to
    http://localhost:8080/05_friends_basic/install
    

    and proceed. (I mention this here because it is not in the tutorial.)

  11. now you may examine the installed user data by pointing your browser to
    http://localhost:8080/05_friends_basic/display
    


  12. play around with it ...

HTH!
fbaube ,at, welho.com



Are you enjoying Confluence? Please consider purchasing it today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.1a Build:#515 May 19, 2006) - Bug/feature request - Contact Administrators