In this second part we’re gonna setup an example database, prepare Glassfish for mysql and finally run seam setup to create the proper build.properties file for deployment to glassfish. I’m using the example schema provided by the excellent Seam in Action book by Manning. The setup scripts can be found in the zip file located here.
To recap I’m using the following file structure as recommended in the Seam in Action book:
- ~/lib: this will contain the mysql driver, which will be copied by seam-gen to the Glassfish server;
- ~/opt: this already contains jboss-seam and the Glassfish server;
- ~/open18: this will contain the seam-gen generated project.
1. Installing the database schema
First download the seaminaction-20090413.zip file and extract it in your home directory.
Now login to the mysql database
$ mysql -u <user_name> -p
Now create a database and run the mysql scripts contained in the zip file
sql> CREATE DATABASE open18; sql> USE open18; sql> source ~/seaminaction/etc/schema/open18-initial-schema-mysql.sql sql> source ~/seaminaction/etc/schema/open18-initial-seed-data-mysql.sql
2. Download and install the mysql driver
Next we’ll gonna provide seam-gen with a recent mysql driver
- First, download the MySQL Connector/J zip file here.
- Unzip this file and copy the mysql-connector-java-5.1.12-bin.jar to your ~/lib directory
The jar will be picked up by seam-gen later on and copied to the Glassfish domain. You can also choose to copy the driver file directly to the Glassfish server by copying the jar file to <glassfish_home>/domain/domain1/lib/ext (assuming you’ll be deploying the seam-gen app to this default domain).
3. Running seam-gen setup
Now it’s time to run seam-gen setup. This will create the proper build.properties file needed for the creation the the NetBeans project later on.
Switch to ~/opt/jboss-seam-2.2.1.CR1 and enter
$ ./seam setup
Answer the questions and verifiy the generated build.properties file in the ~/opt//jboss-seam-2.2.1.CR1/seam-gen directory. It should look like this:
Now all the hard work is done, in the last part of this blog series, we’re gonna create the seam-gen project and deploy it to our Glassfish domain!!