USING MYSQL IN DEVELOPMENT
These steps pertain to JumpStart 4.12.2 and later.
They enable you to develop and test in Eclipse using a MySQL database instead of HSQLDB.
They assume you have installed a MySQL database server. JumpStart has been tested with MySQL Community Server 5.1.40.
- Create database and user.
Using MySQL Workbench, MySQL Query Browser, or your preferred SQL tool:- Log in as user root.
- If the database is on the same machine as your development environment, then execute the following statements.
Otherwise, execute the statements with your development machine's IP address instead of localhost:
- CREATE DATABASE IF NOT EXISTS jumpstart_dev;
- CREATE USER 'jumpstart'@'localhost' IDENTIFIED BY 'jumpstart';
- GRANT ALL PRIVILEGES ON jumpstart_dev.* TO 'jumpstart'@'localhost';
- FLUSH PRIVILEGES;
- Get the MySQL database driver.
- Edit business/build.xml, uncommenting references to mysql-connector-java-5.1.10.jar.
- Using the project's build.xml, run the Ant target get-dependent-files.
- Refresh the project.
- Check that mysql-connector-java-5.1.10.jar is now in business/src/main/lib-runtime/.
- Modify the collapser to copy the right persistence.xml.
- Edit the file collapser.xml, commenting out the line that copies openejb-hibernate-hsqldb-persistence.xml and un-commenting the line that copies openejb-hibernate-mysql-persistence.xml.
- Modify the openejb datasource configuration.
- Edit the file business/src/test/conf/openejb.xml, commenting out the Resource sections involving HSQLDB and un-commenting the Resource sections involving MySQL.
- Also modify the values of JdbcUrl, UserName, and Password to suit your MySQL database.
- Modify the business MANIFEST.MF.
This step is not needed for the development environment, but it's worth doing now - it is needed later if you build an EAR file for an application server.- Edit the file business/src/main/resources/META-INF/MANIFEST.MF, adding ./lib/mysql-connector-java-5.1.10.jar to the Class-Path line.
- Clean the project.
- In Eclipse, choose Project > Clean. . . > jumpstart.
Web Server | Business Server | Persistence | Database Server | Logger |
---|---|---|---|---|
Jetty | OpenEJB | Hibernate | MySQL | Log4j |
(As a user library) | (As a user library) | (As jars in project) | (Provided by you) | (As jars in project) |
- Start Jetty. In Eclipse...
- Choose Run > Run Configurations.... The Run Configurations window will appear.
- Right-click on Java Application and choose New.
- Set the variables to values similar to those shown in the screen shot.
- Click on the Arguments tab.
- Set the VM arguments to the following, replacing the value of openejb.home with yours, eg.:
-Dtapestry.production-mode=false
-Dtapestry.compress-whitespace=false
-Djetty.home=../jetty-6.1.24
-Dorg.mortbay.jetty.webapp.parentLoaderPriority=true
-Dopenejb.home=../openejb-3.1.2
-Dopenejb.configuration=business/src/test/conf/openejb.xml
-Dhibernate.hbm2ddl.auto=update
-Xms192m
-Xmx192m
-XX:MaxNewSize=96m
-XX:MaxPermSize=96m - These properties are explained here: tapestry, jetty, openejb, hibernate, JVM.
We have to "spell out" the classpath to jetty to avoid classloader issues. - Click on the Classpath tab.
- Remove the
(default classpath)
entry. - Click on User Entries.
- Add folder
web/src/test/conf
. - Add folder
collapsed/jumpstart.war/WEB-INF/classes/
. - Add all JARs from these folders:
collapsed/jumpstart.war/WEB-INF/lib/
business/src/main/lib-provided/
web/src/main/lib-provided/
web/src/test/lib-test/
- Add user library
jetty-6.1.24-lib
. - Add user library
openejb-3.1.2-lib
. - Remove these JARs because they are also in the user library:
jetty-6.1.24.jar - /jumpstart-n/web/src/main/lib-test/
jetty-util-6.1.24.jar - /jumpstart-n/web/src/main/lib-test
- Remove these JARS because they are duplicates:
javaee-api-n.n-n.jar - /jumpstart-n/web/src/main/lib-provided/
joda-time-n.n.jar - /jumpstart-n/web/src/main/lib-provided/
slf4j-api-n.n-n.jar - /jumpstart-n/web/src/main/lib-provided/
- Move the two folders to the top. It avoids conflicts.
- Click Run.
- If error, especially
ClassNotFoundException
fororg.slf4j.Logger
ororg.slf4j.impl.StaticLoggerBinder
, check the Arguments and classpath match those shown above. - Check JumpStart is running by pointing your web browser at http://localhost:8080/jumpstart.
- Populate the MySQL database:
Using MySQL Workbench, MySQL Query Browser, or your preferred SQL tool:- Log in as user root or jumpstart.
- Connect to database schema jumpstart_dev if you haven't already done so, eg. with this statement: USE DATABASE jumpstart_dev;.
- Run the script business/src/test/data/initial_data.sql (you may prefer to open the script in Eclipse and copy and paste it into the tool).
- Confirm you can log in by going to
http://localhost:8080/jumpstart/theapp/login
and logging in as secofr with password secofr.
There are another 2 users: admin and john, with passwords admin and john, respectively. - That's it!