TicketMonster Tutorial

What is TicketMonster?


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.

Use cases

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;

  • book tickets;

  • view current bookings;

  • cancel bookings;

Figure 1. End user use cases

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;

Figure 2. Administration use cases


Figure 3. TicketMonster architecture

The application uses Java EE 6 services to provide business logic and persistence, utilizing technologies such as CDI, EJB 3.1 and JAX-RS, JPA 2. These services back the user-facing booking process, which is implemented using HTML5 and JavaScript, with support for mobile devices through jQuery Mobile.

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.

Building TicketMonster

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

Running TicketMonster

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.

  1. Open a command line and navigate to the root of the JBoss server directory.

  2. 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.

  1. Make sure you have started the JBoss Server as described above.

  2. 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)

  3. This will deploy target/ticket-monster.war to the running instance of the server.

  4. Now you can see the application running at http://localhost:8080/ticket-monster.

Running TicketMonster in OpenShift

First, create an OpenShift project.

  1. 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). If you want to use PostgreSQL, add the postgresql-8.4 cartridge too.

  2. Ensure that the Git repository of the project is checked out.

Then, build and deploy it.

  1. 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
  2. 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
  3. Navigate to <root-of-openshift-application-git-repository> folder

  4. Remove the existing src folder and pom.xml file.

    git rm -r src
    git rm pom.xml
  5. Add the copied file to the repository, commit and push to Openshift

    git add deployments/ROOT.war
    git commit -m "Deploy TicketMonster"
    git push
  6. Now you can see the application running at at http://<app-name>-<domain-name>.rhcloud.com

Learn more

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;

  • implement a mobile-ready front-end using HTML 5, JSON, JavaScript and jQuery Mobile;

  • 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.

Share the Knowledge

Find this guide useful?


Find a bug in the guide? Something missing? You can fix it by [forking the repository](http://github.com/jboss-jdf/ticket-monster), making the correction and [sending a pull request](http://help.github.com/send-pull-requests). If you're just plain stuck, feel free to ask a question in the [user discussion forum](http://site-jdf.rhcloud.com/forums/jdf-users).

Recent Changelog

  • Jul 13, 2013: Converted the preface section of the book into it's own chapter Vineet Reynolds
  • Jul 13, 2013: Forge-345 improved the styling for code listings Vineet Reynolds
  • Jul 10, 2013: Modified the tutorial generator to use asciidoctor Vineet Reynolds
  • Jun 27, 2013: Oops. changes to tax headers removed the authors metadata. correcting it Rafael Benevides
  • Jun 24, 2013: Switching from setex to tax headers completely Rafael Benevides
  • Jun 24, 2013: Jdf-378 - correct warnings on asciidoctor about invalid levels Rafael Benevides
  • May 21, 2013: Jdf-171 fixed link for getting started with openshift Vineet Reynolds
  • 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

See full history »