Running the Heat Clinic locally
Goals
This tutorial is designed to get the Heat Clinic running in your local environment using the command prompt for your operating system. By the end of this tutorial you will have the consumer-facing Heat Clinic store running locally, as well as, the Broadleaf admin, which is used to manage the Heat Clinic data.
Prerequisites
The Java 8 Development Kit: either the official Oracle JDK or Open JDK
The latest version of Maven - 3.3.1 minimum, the latest version is recommended)
Need help installing the pre-requisites on Windows, OSX, or Linux?
Windows Installation
Java
Download the Java 8 JDK from Oracle's website and install. After installation, in order for other dependencies to work correctly (like Maven) you need to ensure that the JAVA_HOME
environment variable is set. Follow the tutorial at http://www.mkyong.com/java/how-to-set-java_home-on-windows-10/ for Windows 10 and https://kaanmutlu.wordpress.com/2013/04/26/setting-the-java_home-in-windows-7-64-bit/ for Windows 7.
These tutorials will also make the java
command available on the command line (the Java installer might have already done this). To validate that everything is installed correctly, open up a command prompt (cmd.exe
) and type:
$ echo %JAVA_HOME%
$ java -version
Those commands should print out the path to where Java is installed and then print out the Java version (which should contain 1.8 in the version)
Maven
Download the latest version of Maven from the Maven downloads section. Then, follow these additional instructions to ensure that the mvn
executable is on your path.
To test that Maven was installed correctly, you should be able to type mvn -v
in the command prompt and get something like:
$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: C:\apache-maven-3.3.9\bin\..
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_77\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"
Mac/OSX
Java
Follow the link to install Oracle JDK 8. To verify that this is installed correctly, open up Terminal and type:
$ java -version
Then, to properly set the JAVA_HOME
environment variable for Maven, execute this command:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
It is a good idea to put this in your
~/.bash_profile
or equivalent file for your shell
Maven
The easiest way to install Maven is through a utility called Homebrew. Once Homebrew is installed open Terminal and type:
$ brew install maven
To verify that it is installed correctly type mvn -v
in a Terminal. You should get output like:
$ mvn -v Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.4", arch: "x86_64", family: "mac"
Linux
Java
Use you favorite dependency management tool to download Java. Note that in Java 8 might not be the default in your distribution, and you might have to add an extra repository for the Oracle JDK. For instance, in Ubuntu, this adds the PPA for the Oracle Java 8 JDK:
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
You also need to set the JAVA_HOME
environment variable to where the JDK is installed for Maven. The path can be determined automatically with this command:
$ export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
Maven
First, check to see if your package manager has a maven
package (e.g. apt-get install maven
). Use mvn -v
to verify the version; it should be at least 3.2.
If not, download the latest version of Maven from the Maven downloads section. Extract the directory to somewhere that you will remember, like /usr/local/apache-maven-3.3.9
. Finally, add the mvn
executable to your PATH
environment variable with:
$ export PATH=/usr/local/apache-maven-3.3.9/bin:$PATH
To verify the installation, you should be able to execute the following:
$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00)
Maven home: /usr/local/apache-maven-3.3.9
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.2.0-34-generic", arch: "amd64", family: "unix"
Steps
Now that all of the pre-requisites are installed, let's set up the Heat Clinic.
Install Broadleaf
- Download the latest 5.1 Community Edition. Anyone can use the community edition to get hands on with core Broadleaf concepts like extension patterns and more in non-production environments. Only qualifying customers can use this edition in production
- Once you have the latest version of the Heat Clinic downloaded, unzip it and keep note of the location.
- At the command line for your operating system, change your directory to where the Heat Clinic is unzipped. Type
mvn install
and hit enter.
This might take a while as all of the Broadleaf dependencies are downloaded
Start the Admin
Now let's start up the Heat Clinic admin by going into the
admin
directory from the command line and executing:OSX/Linux
$ ./startadmin.sh
Windows
$ startadmin.bat
Once this has finished, load the admin by going to http://localhost:8081/admin in your browser. The username/password is admin/admin
Start the Site
After this is complete, start up the Heat Clinic frontend by going into the
site
directory from the command line and executing:OSX/Linux
$ ./startsite.sh
Windows
$ startsite.bat
Once this has finished executing, you should be able to see the Heat Clinic by going to http://localhost:8080 in your browser
Next Steps
Now that you have Broadleaf up and running, here are some places you might go to next:
- Import the Heat Clinic into your IDE
- Change the database to MySQL, Postgres, Oracle, or SQL Server
FAQ
Where is the Heat Clinic data stored? (Show Answer)
The Heat Clinic starts up with an embedded HSQL database, stored as a flatfile in the data
directory of the root of the Heat Clinic project (this folder should be ignored from version control in your .gitignore
file). You can browse this database with something like SquirrelSQL. You can also switch to another database to use Oracle, MySQL, Postgres or SQLServer.
Why did my data get wiped after a reboot? (Show Answer)
By default the Heat Clinic is configured to drop all tables and re-run import scripts on startup in the development
runtime environment (the default for local development). In site/src/main/resources/runtime-properties/development.properties
and also in admin/src/main/resources/runtime-properties/development.properties
you will find these properties:
blPU.hibernate.hbm2ddl.auto=
blEventPU.hibernate.hbm2ddl.auto=
blSecurePU.hibernate.hbm2ddl.auto=
blEventPU.hibernate.hbm2ddl.auto=
There are 5 possible values for these properties:
validate
- validate the database schema with the Hibernate data model, makes no changes to the database. Throws an exception if the database schema and the Hibernate model do not matchupdate
- update the database schema with the Hibernate data model (e.g. add columns, foreign keys, tables). This will not change the underlying data inside the tables, but it is possible that you have invalid data after executing the update.create
- on startup, this executes adrop
on all tables and data in the schema. Then all tables are re-created, and data load SQL is imported as specified by<unit_name>..hibernate.hbm2ddl.import_files
like indevelopment-shared.properties
.create-drop
- on startup, do the same thing as thecreate
value. On shutdown, drop the entire schema including all data and tablesnone
- do not do anything when comparing the Hibernate model to the database schema
Where does the Heat Clinic get all of its data for initial load? (Show Answer)
In the core project there is a set of SQL scripts that are executed. These scripts are in core/src/main/resources/sql
. These SQL files are referenced as import files in core/src/main/resources/runtime-properties/development-shared.properties
. Some Broadleaf add-on modules also add demo data. These files are referenced in the same common-shared.properties
files, but they are prefixed by /config/bc/sql
.
Why do I see error messages like 'HHH000389: Unsuccessful: alter table ...'? (Show Answer)
When the Heat Clinic first starts up, you might see a lot of these types of error messages in your logs:
[ERROR] 08:38:08 SchemaExport [admin][][] - HHH000389: Unsuccessful: alter table BLC_PAYMENT_LOG drop constraint FKA43703453E2FC4F9
[ERROR] 08:38:08 SchemaExport [admin][][] - user lacks privilege or object not found: PUBLIC.BLC_PAYMENT_LOG
[ERROR] 08:38:08 SchemaExport [admin][][] - HHH000389: Unsuccessful: alter table BLC_PAYMENT_LOG drop constraint FKA43703457470F437
[ERROR] 08:38:08 SchemaExport [admin][][] - user lacks privilege or object not found: PUBLIC.BLC_PAYMENT_LOG
[ERROR] 08:38:08 SchemaExport [admin][][] - HHH000389: Unsuccessful: alter table BLC_PGTMPLT_FLDGRP_XREF drop constraint FK99D625F66A79BDB5
[ERROR] 08:38:08 SchemaExport [admin][][] - user lacks privilege or object not found: PUBLIC.BLC_PGTMPLT_FLDGRP_XREF
This is a known bug that exists in Hibernate. This only occurs when the schema has never been created before and the hbm2ddl.auto
is set to create
or create-drop
. These messages are harmless and can safely be ignored.
How do I shutdown or restart just the embedded HSQL database? (Show Answer)
In either the site or admin project, execute mvn antrun:run@hsqldb-stop
. You can also start up the HSQLDB instance in either the site or admin projects with mvn antrun:run@hsqldb-start