Quickstarts

helloworld-html5: HTML5 + REST Hello World Example

What is it?

This example demonstrates the use of CDI 1.0 and JAX-RS in JBoss AS 7 using the HTML5 + REST architecture. The application is basically a smart, HTML5+CSS3+JavaScript front-end using RESTful services on the backend.

The example can be deployed using Maven from the command line or from Eclipse using JBoss Tools.

System requirements

All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven 3.0 or better.

The application this project produces is designed to be run on JBoss AS 7 or JBoss Enterprise Application Platform 6.

An HTML5 compatible browser such as Chrome, Safari 5+, Firefox 5+, or IE 9+ are required.

With the prerequisites out of the way, you're ready to build and deploy.

Deploying the application

Deploying locally

First you need to start the JBoss container. To do this, run

$JBOSS_HOME/bin/standalone.sh

or if you are using windows

$JBOSS_HOME/bin/standalone.bat

To deploy the application, you first need to produce the archive to deploy using the following Maven goal:

mvn package

You can now deploy the artifact by executing the following command:

mvn jboss-as:deploy

This will deploy both the client and service applications.

The application will be running at the following URL http://localhost:8080/jboss-as-helloworld-html5/.

To undeploy run this command:

mvn jboss-as:undeploy

You can also start the JBoss container and deploy the project using JBoss Tools. See the Getting Started Developing Applications Guide for more information.

Deploying to OpenShift

You can also deploy the application directly to OpenShift, Red Hat's cloud based PaaS offering, follow the instructions here

Importing the project into an IDE

Detailed instructions for using Eclipse / JBoss Tools with are provided in the Getting Started Developing Applications Guide.

If you created the project from the commandline using archetype:generate, then you need to import the project into your IDE. If you are using NetBeans 6.8 or IntelliJ IDEA 9, then all you have to do is open the project as an existing project. Both of these IDEs recognize Maven projects natively.

Downloading the sources and Javadocs

If you want to be able to debug into the source code or look at the Javadocs of any library in the project, you can run either of the following two commands to pull them into your local repository. The IDE should then detect them.

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

Development notes

You can test the REST endpoint using the following URL http://localhost:8080/<artifactId>/hello/json/David/.

HelloWorld.java - establishes the RESTful endpoints using JAX-RS

Web.xml - maps RESTful endpoints to "/hello"

index.html - is a jQuery augmented plain old HTML5 web page

To update the copyright headers, just run mvn license:format -Dyear=<current year>

Share the Knowledge

Find this guide useful?

Feedback

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.

Recent Changelog

  • Mar 21, 2013: Jdf-235 move aerogear quickstart to jdf Rafael Benevides
  • Feb 12, 2013: Add quickstart source repository of record to the readme files Sande Gilda
  • Dec 13, 2012: Update readme, aerogear-365 Lucas Holmquist
  • Sep 24, 2012: Merge aerogear/as-quickstart '1.0.0.m6' Kris Borchers
  • Sep 17, 2012: Add origin metadata to the quickstart readme Bruno Oliveira
  • Sep 13, 2012: Tweak the tutorial urls to be more consistent Bruno Oliveira
  • Sep 11, 2012: Fix incorrect product targets Sande Gilda
  • Sep 11, 2012: Add target product (https://issues.jboss.org/browse/jdf-108) Sande Gilda
  • Aug 22, 2012: Merge of changes from the latest updates on aerogear to m5 Bruno Oliveira
  • Jun 06, 2012: Replace the term poh5 by html5+rest Bruno Oliveira
  • Jun 04, 2012: Remove poh5 reference Pete Muir
  • May 18, 2012: Move metadata to quickstarts Pete Muir
  • Mar 13, 2012: Merging 1.0.0.m2c from aerogear/as-quickstarts Kris Borchers
  • Feb 23, 2012: Adding openshift deploy instructions to the readme.md Douglas Campos
  • Feb 23, 2012: Update helloworld readme aerogear-95 Wesley Hales

See full history »