Getting Java TPC-W to work with Postgresql and Tomcat

There is a publicly available TPC-W Java implementation written as part of Prof. Mikko Lipasti's ECE 902 course at the University of Wisconsin-Madison. This page provides some information for people who want to get this implementation to work with the Tomcat servlet container and Postgresql databases, I hope it is useful and can safe you some time.

Amit Manjhi from Carnegie Mellon University, described on his page how to change the code to fit a Tomcat + Mysql environment, this was a good starting point when introducing the needed changes.

I used the following components to do experiments with the TPC-W Java code:

  • Tomcat Servlet Container (jakarta-tomcat-4.1.24-LE-jdk14)
  • Sun J2SDK (j2sdk1.4.1_02)
  • Postgresql (Postgresql 7.3.2 and the included JDBC driver)
  • Here is a list of things I did:

    • changed "double" to "double precision" in the table CREATE statements in
    • changed JDBC URL and JDBC driver to match Postgresql DB in
    • generated images and populated database, be sure to have plenty of time + diskspace, for 10000 items the images consume like 2.6 gigabytes of diskspace
    • copied the images to $CATALINA_HOME/webapps/ROOT/tpcw/Images. Be careful, Tomcat does not follow symlinks by default, actually my version cannot do it at all, so the huge amount of pictures must be on the same mountpoint as the webapps. Hardlinks work, btw.
    • changed
      static String driverName = "org.postgresql.Driver";
      static String jdbcPath = "jdbc:postgresql://mydbhost/tpcw";
      in (same change as in
    • changed "FETCH FIRST xyz ROWS ONLY" to "LIMIT xyz" at several places in
    • changed issues with dates in
      "CURRENT TIMESTAMP" to "timestamp 'now'"
      "CURRENT TIMESTAMP + 2 HOURS" to "timestamp 'now' + interval '2 hours'"
      "CURRENT DATE" to "date('now')"
      "CURRENT DATE + ? DAYS" to "date('now') + ?"
    • in all servlets, did replacing of
      ";$sessionid$" to ";jsessionid="
      "encodeUrl" to "encodeURL" (this one is not so important, just used to get rid of some deprecated messages)
    • in, changed ";$sessionid$" to ";jsessionid="
    • in and
      changed "SCIENCE-FICTION" to "SCIENCE_FICTION" (actually the bug is in, but at that time I already had generated the tables,
      so I decided to fix the servlets and the rbe. It would be cleaner to
      fix it in, but then I would have had to regenerate the
      database, or to fix the rows containing the wrong string)
    • in and there are issues with CX_EXPIRY which is sometimes called CX_EXPIRE, better change it
    • installed a custom web.xml to enable the servlets ($CATALINA_HOME/webapps/ROOT/WEB-INF/web.xml)
      Actually including the following snippet
      into the already present web.xml file should do the trick.
    • compiled and copied servlets + classes to the $CATALINA_HOME/webapps/ROOT/WEB-INF/classes (one has to create that one first) directory

    11.06.2003: I discovered a recent distrubution of the Java TPC-W which eases the configuration of the SQL statements. You can download it from Jan Kiefer's site.

    Questions or suggestions? Please drop me a line.

    Last changes: Christian Plattner, 11-Jun-2003 (first version 28-May-2003)