TermComp
TermComp Blog
Setting up a local development environment
This article describes how to check out the termcomp sources from SVN and hook them up to a development database as well as how to get a development environment configured.
The steps for checking out and setting up a development environment are as follows:
- Download and install Eclipse for Java EE
- download and set up a JBoss server
- set up a postgresql database
- check out the sources
- configure your local database connection
- configure your local build environment
1. Downloading Eclipse
Go to http://www.eclipse.org/downloads/ and download “Eclipse for Java EE Developers” for the operating system of your choice.
2. Obtaining JBoss
Jboss can be downloaded from http://www.jboss.org/jbossas/downloads/. The version used on the competition server is 4.2.2.GA. Download the zip file, unzip and put somewhere where your normal working user will have write access to it. This directory will now be referred to as $JBOSS_HOME.
Find the file $JBOSS_HOME/bin/run.conf and set the JAVA_OPTS variable to the following content (this should all be on one line):
JAVA_OPTS="-Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024
-Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
Icing on the cake
Download and install the JBoss Tools for Eclipse – they make life a bit easier. Then create a JBoss server pointing at $JBOSS_HOME which will allow you to manage your JBoss server and view the server logs from within Eclipse.
3. Set up a PostgreSQL database
Setting up a PostgreSQL server is outside the scope of this article. However, the following steps are needed:
- Install and set up the server
- Create two users, one of which can create databases, the other should have no rights
- Create a database with the user created in the previous step
- Grant SELECT, INSERT, UPDATE and DELETE rights to the unprivileged user
- Potentially import a current SQL dump of the active termcomp database
A current SQL dump can be supplied on request – if there is enough demand, nightly dumps will be made available.
4. Check out the sources
The sources for termcomp can be checked out from http://dev.aspsimon.org/svn/termcomp/. The folder structure which is checked out can be imported directly into eclipse as an existing project.
5. Configure your local database connection
The project you just checked out contains a zip file datasource-files.zip. Unzip this file in the project directory. In the ./resources directory, edit the two new files termcomp-dev-ds.xml and termcomp-prod-ds.xml. In the dev file, put the user who has full privileges on the database, in the prod file, put the user who only has SELECT, INSERT, UPDATE and DELETE rights.
One of these two files is selected by the ant build process, depending on the content of the $profile variable. The difference is that dev will update the database schema on deploy whereas prod will only validate the schema and complain (and fail) if the schema is not consistent with the entity objects. It is generally a good idea to use prod unless you have changed any entity objects.
Also edit the ./hibernate-console.properties to reflect your database connection (use the less privileged user) – this will allow you to use the hibernate console in eclipse to try out hibernate queries.
6. Configure the build environment
You should now be almost ready to compile and deploy the termcomp application to your local test server. One final step remains: tell the build environment where your JBoss server is located. Edit the file ./build.properties and change the variable jboss.home to the absolute path of the $JBOSS_HOME you setup in step 2.
Now open the ./build.xml file. You will see many targets, the most important ones for development are explode, unexplode, clean and restart. What they do is explained below:
- explode
- Copies the compiled application structure to $JBOSS_HOME/server/default/deploy, thus hot-deploying the application to your JBoss server;
- unexplode
- Removes the deployed application from the JBoss server – very useful if you renamed classes;
- clean
- Cleans the build path in your project – also very useful if you renamed classes;
- restart
- Tells the JBoss server to reinitialize the application – required when you change any underlying Java objects, but not if you change any JSF pages.
Eclipse will automatically copy changed files to the exploded application if it is deployed, but Java objects are only reloaded if the application is restarted (restart target). Changed frontend .xhtml pages are automatically detected, however.
An overview of the project structure will be provided in a different document.
Icing on the cake
Use the bugzilla integration in Eclipse’s Mylyn to hook up your Eclipse to the bugzilla repository at http://dev.aspsimon.org/bugzilla/.