USING MYSQL IN DEVELOPMENT
These steps pertain to JumpStart 6.1.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.53.
- 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.
- Download the mysql-connector-java-5.1.20.jar from http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.20/ .
- Move it to OpenEJB's lib/ directory, eg. /devel/apache-openejb-4.5.0/lib/ .
- Modify the choice of persistence descriptor.
- In Eclipse, edit the file build.properties, modifying the value of this property: collapsed.persistence.descriptor.
- Modify the datasource configuration.
- In Eclipse, 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 user library.
- In Eclipse, choose Window > Preferences > Java > Build Path > User Libraries (or in OS X, choose Eclipse > Preferences... > Java > Build Path > User Libraries), and
- Click on the existing library, eg. apache-openejb-4.5.0-mysql-lib, then
- Click Add Jars... and add the MySQL driver from OpenEJB's lib/ directory.
- 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, you can run the existing configuration with one modification...
- Choose Run > Run Configurations.... The Run Configurations window will appear.
- Choose your existing configuration, eg. Java Application > jumpstart.
- Click on the Arguments tab.
- Add the following VM argument:
-Dopenejb.configuration=business/src/test/conf/openejb.xml
- The property is explained here: openejb.
- 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!