TicketMonster is an example application that focuses on Java EE6 - JSF 2, JPA 2, CDI and JAX-RS along with HTML5, jQuery Mobile, JSF and GWT. It is a moderately complex application that demonstrates how to build modern web applications optimized for mobile & desktop. TicketMonster is representative of an online ticketing broker - providing access to events (e.g. concerts, shows, etc) with an online booking application.
Apart from being a demo, TicketMonster provides an already existing application structure that you can use as a starting point for your app. You could try out your use cases, test your own ideas, or, contribute improvements back to the community.
The accompanying tutorials walk you through the various tools & technologies needed to build TicketMonster on your own. Alternatively you can download TicketMonster as a completed application and import it into your favorite IDE.
Before we dive into the code, let’s discuss the requirements for the application.
We have grouped the current use cases in two major categories: end user oriented, and administrative.
What can end users do?
The end users of the application want to attend some cool events. They will try to find shows, create bookings, or cancel bookings. The use cases are:
look for current events;
look for venues;
select shows (events taking place at specific venues) and choose a performance time;
view current bookings;
What can administrators do?
Administrators are more concerned the operation of the business. They will manage the master data: information about venues, events and shows, and will want to see how many tickets have been sold. The use cases are:
add, remove and update events;
add, remove and update venues (including venue layouts);
add, remove and update shows and performances;
monitor ticket sales for current shows;
The administration site is centered around CRUD use cases, so instead of writing everything manually, the business layer and UI are generated by Forge, using EJB 3.1, CDI and JSF. For a better user experience, Richfaces UI components are used.
Monitoring sales requires staying in touch with the latest changes on the server side, so this part of the application will be developed in GWT and showcases Errai’s support for real-time updates via client-server CDI eventing.
How can you run it?
Before building and running TicketMonster, you must generate the administration site with Forge. See the tutorial for details.
TicketMonster can be built from Maven, by runnning the following Maven command:
mvn clean package
If you want to run the Arquillian tests as part of the build, you can enable one of the two available Arquillian profiles.
For running the tests in an already running application server instance, use the arq-jbossas-remote profile.
mvn clean package -Parq-jbossas-remote
If you want the test runner to start an application server instance, use the arq-jbossas-managed profile. You must set up the JBOSS_HOME property to point to the server location, or update the src/main/test/resources/arquillian.xml file.
mvn clean package -Parq-jbossas-managed
If you intend to deploy into OpenShift, you can use the postgresql-openshift profile:
mvn clean package -Ppostgresql-openshift
You can run TicketMonster into a local JBoss AS7 instance or on OpenShift.
Running TicketMonster locally
First, start JBoss Enterprise Application Platform 6 or JBoss AS 7 with the Web Profile.
Open a command line and navigate to the root of the JBoss server directory.
The following shows the command line to start the server with the web profile:
For Linux: JBOSS_HOME/bin/standalone.sh For Windows: JBOSS_HOME\bin\standalone.bat
Then, deploy TicketMonster.
Make sure you have started the JBoss Server as described above.
Type this command to build and deploy the archive into a running server instance.
mvn clean package jboss-as:deploy
(You can use the `arq-jbossas-remote` profile for running tests as well)
This will deploy target/ticket-monster.war to the running instance of the server.
Now you can see the application running at http://localhost:8080/ticket-monster.
Running TicketMonster in OpenShift
First, create an OpenShift project.
Make sure that you have an OpenShift domain and you have created an application using the jbossas-7 cartridge (for more details, get started [here](https://openshift.redhat.com/app/getting_started)). If you want to use PostgreSQL, add the postgresql-8.4 cartridge too.
Ensure that the Git repository of the project is checked out.
Then, build and deploy it.
Build TicketMonster using either:
the default profile (with H2 database support)
mvn clean package
the postgresql-openshift profile (with PostgreSQL support) if the PostgreSQL cartrdige is enabled in OpenShift.
mvn clean package -Ppostgresql-openshift
Copy the target/ticket-monster.war file in the OpenShift Git repository(located at <root-of-openshift-application-git-repository>).
cp target/ticket-monster.war <root-of-openshift-application-git-repository>/deployments/ROOT.war
Navigate to <root-of-openshift-application-git-repository> folder
Remove the existing src folder and pom.xml file.
git rm -r src git rm pom.xml
Add the copied file to the repository, commit and push to Openshift
git add deployments/ROOT.war git commit -m "Deploy TicketMonster" git push
Now you can see the application running at at http://<app-name>-<domain-name>.rhcloud.com
The example is accompanied by a series of tutorials that will walk you through the process of creating the TicketMonster application from end to end.
After reading this series you will understand how to:
set up your project;
define the persistence layer of the application;
design and implement the business layer and expose it to the front-end via RESTful endpoints;
develop a JSF-based administration interface rapidly using JSF and JBoss Forge;
thoroughly test your project using JUnit and Arquillian;
Throughout the series, you will be shown how to achieve these goals using JBoss Developer Studio.
Find this guide useful?
Find a bug in the guide? Something missing? You can fix it by forking the repository, making the correction and sending a pull request. If you're just plain stuck, feel free to ask a question in the user discussion forum.
- Jan 24, 2013: Fix syntax errors that upset asciidoctor Dan Allen
- Jul 03, 2012: Fix link, thanks to abhinav Pete Muir
- Jun 22, 2012: Corrected openshift deployment instructions Marius Bogoevici
- Jun 21, 2012: Switch section level to fit docbook's expectations for a preface Marius Bogoevici
- Jun 18, 2012: Add 'how to run' section Marius Bogoevici
- Jun 18, 2012: Fix chapter headings Marius Bogoevici
- Jun 18, 2012: Fix diagram Marius Bogoevici
- Jun 01, 2012: Minor changes to be a bit less wordy Pete Muir
- May 30, 2012: Rename files without ordering, finish off single book output Pete Muir
- May 29, 2012: Numbered files for proper ordering Marius Bogoevici
- May 28, 2012: Add author info Pete Muir
- May 24, 2012: Added author tags for the document Marius Bogoevici
- May 24, 2012: What is tm - revisited Marius Bogoevici
- May 22, 2012: Structure improvements Marius Bogoevici
- May 18, 2012: Fix image rendering issues Marius Bogoevici