-
Notifications
You must be signed in to change notification settings - Fork 15
Project Setup
Headmaster consists of three primary runtime components: the database, the web service, and the client web application. Setup instructions are provided in that order.
-
Download, install, and start up your chosen relational database server.
-
Initialize Headmaster’s destination database/namespace/schema.
For PostgreSQL, this means invoking
createdb <database name>. -
If you want to run the unit tests, you should also create a separate database/namespace/schema for these tests.
-
See below for instructions on how to initialize the database schema.
To build and deploy:
-
Copy
SAMPLE-build.propertiestobuild.properties. -
Fill in the database username, password and any other missing properties that don't get checked into the repository.
You will need to create two empty databases: one for production and another for testing. The testing database is touched during the build sequence, when unit tests are run.
-
If you have not initialized a production database yet, set the
build.propertiesfile’shibernate.hbm2ddl.autoproperty tocreate:`hibernate.hbm2ddl.auto=create`There is no need to initialize the testing database because the build sequence initializes it for you.
-
Install a
log4j.xmlinsrc/main/resourcesif desired. ASAMPLE-log4j.xmlstarting point is available at the project root. -
mvn clean package -
Your
warfile is intarget/: deploy as you wish.For Tomcat, this means copying the
warfile to$TOMCAT/webapps. -
Configure your app server for authentication. For Tomcat, do this:
- Copy the PostgreSQL JDBC library to
$TOMCAT/lib. - Edit
$TOMCAT/conf/server.xml. - Replace or comment out this block*...*
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>- ...with this block (note the substitutions):
<Realm className="org.apache.catalina.realm.JDBCRealm" driverName="org.postgresql.Driver" connectionURL="jdbc:postgresql://***database/host/and/name***" connectionName="***database-username***" connectionPassword="***database-password***" userTable="serviceuser" userNameCol="login" userCredCol="challenge" userRoleTable="userrole" roleNameCol="rolename" digest="sha-512" /> - Copy the PostgreSQL JDBC library to
-
Start up your app server.
- For Tomcat, this means running
$TOMCAT/bin/startup.sh. - If you run into memory issues with Tomcat, create the file
$TOMCAT/bin/setenv.shwith the following content:
JAVA_OPTS="-Xmx1024m -XX:MaxPermSize=512m -XX:PermSize=512m -XX:+CMSClassUnloadingEnabled" - For Tomcat, this means running
-
If you set
hibernate.hbm2ddl.auto=create, this first run will have initialized the database schema and loaded it with some startup data. Stop your app server ($TOMCAT/bin/shutdown.shfor Tomcat), change this setting tohibernate.hbm2ddl.auto=validateinbuild.properties, then rebuild and redeploy thewarfile. -
URIs to try in your browser (the default initial user is
headmasterwith passwordheadmaster:
http://localhost:8080/headmaster/users/login/headmasterhttp://localhost:8080/headmaster/students?q=joneshttp://localhost:8080/headmaster/events?q=convo
The latter two service calls will return 404s until you add data that match those queries, but at least they will show you that things are up and running.
-
For other methods like PUT and POST, you'll want to get Poster,
curl, or any other web service capable HTTP client. -
If you are using Eclipse, designate the following as source folders:
src/main/javasrc/main/resourcessrc/test/javasrc/test/resourcestarget/generated-sources/jaxb
-
Copy
SAMPLE-build.propertiestobuild.properties. -
The main property to set for the client is
service.root: i.e., the root URL for the web service. The default valueservice.root=http://localhost:8080/headmaster/denotes that the web service is hosted by the same machine as the web app with/headmasterat the top of the URL's path. -
The
wicket.deploymentproperty is specific to Apache Wicket, which is the framework used by the client web app. Please refer to http://wicket.apache.org for details on Wicket development and deployment builds. -
Install a
log4j.xmlinsrc/main/resourcesif desired. ASAMPLE-log4j.xmlstarting point is available at the project root. -
mvn clean package -
Your
warfile is intarget/: deploy as you wish.For Tomcat, this means copying the
warfile to$TOMCAT/webapps. -
Point your web browser at
http://hostname:8080/headmaster-client.
Client Web App Setup: Quick-Run with the Tomcat Maven Plugin
For quicker client web app development turnaround, you can run the client web app directly from Maven through the Tomcat Maven Plugin. You still need access to a Tomcat instance that is running the web service, but that service runs independently of the client web app.
-
Follow steps 1-4 in the Client Web App Setup: Tomcat Standalone section above.
-
mvn tomcat7:run -
Point your web browser at
http://hostname:9090/headmaster-client, wherehostnameis the machine that is executingmvn tomcat7:run(e.g.,localhostif you are doing everything on one computer).Note the distinct port number, to avoid conflicts in case you are also running standard Tomcat on your machine.
-
Hit
Ctrl-Cto stop the server.