Setting up for Hibernate Projects


Download: pizza_hib.zip

Development system:  any platform supporting java, at least Java 5, properly. I use Windows XP and Solaris UNIX.

For simple exploration of sources and execution, you do not need to install a whole IDE, just Java and ant. The needed .jar files are available in pizza's lib and WebContents/WEB-INF/lib directories. See the readme.txt files in those directories for information on where they came from.

For the simpler client-server system, running on HSQLDB, the in-memory DB (no permanent data), very convenient and fast for testing.
  1. Make sure you have at least Java 5, preferably Java 6.  "java -version" shows the version in the form 1.6 for version 6.
  2. Make sure you have ant with ANT_HOME defined as an environment variable. If you have eclipse, you have an ant installation, and need only find it and set ANT_HOME=<location of  eclipse/plugins/org.apache.ant_1.6.5 directory> in your environment.
  3. Start HSQLDB with "ant startdb"
  4. Run pizza's SystemTest with "ant run". It will compile the sources first.
For running the web app version using tomcat as a (simple) application server, and HSQLDB.
  1. Make sure you have at least Java 5, preferably Java 6, and ant, as above.
  2. Download tomcat v 5.5.x and expand it into some convenient directory. Define its directory name as an environment variable CATALINA_HOME. Tomcat 5.5 runs fine on a Java 6 runtime, faster than on Java 5.
  3. Add a JNDI name for HSQLDB in tomcat's conf/context.xml (or copy tomcat/context.xml to tomcat's conf directory)
  4. Copy lib/hsqldb.jar to tomcat's common/lib, so tomcat can create a working DataSource object for HSQLDB in its JNDI repository.
  5. Start HSQLDB with "ant startdb".
  6. Start tomcat with tomcat's bin/startup.{sh,bat} (or use the eclipse Servers window)
  7. Set your tomcat's path CATALINA_HOME  in build.xml.
  8. Deploy the project to tomcat with "ant deploy"
  9. Browse to http://localhost:8080/pizza/welcome.html. Choose admin, Initialize DB, and add pizza toppings and sizes to get started.
For GUI project development, web app deployment, and debugging, make sure you have a recent "JEE package" version of eclipse.

To run on a real database, obtain its JDBC driver (ojdbc14.jar for Oracle, for example) and treat it like hsqldb.jar, that is, put it in lib,  and for a web app, in WebContent/WEB-INF/lib and tomcat's common/lib directories.  Add an entry in tomcat's context.xml, or your app server's JNDI config. See the commented-out entries in src/java/hibernate.cfg.xml and tomcat/context.xml for Oracle and MySQL.

Home