Chapter 3. Seam Tutorial

3.1. Using the Seam examples

Seam provides a number of example applications that demonstrate the use of a variety of Seam's features. This tutorial guides you through a few examples to help you start learning Seam. The Seam examples are located in the examples subdirectory of the Seam Demo file distributed with Red Hat JBoss Web Framework Kit. The first example, on registration, is in the examples/registration directory.
All examples have similar directory structure based on Maven project structure defaults:
  • The <example>-ear directory contains enterprise application submodule files such as aggregator for web application files, and EJB project.
  • The <example>-web directory contains web application submodule view-related files such as web page templates, images, and stylesheets.
  • The <example>-ejb directory contains Enterprise Java Beans components and integration tests.
  • The <example>-ftest directory contains functional tests.
  • The <example>-web/src/main/webapp directory contains view-related files such as web page templates, images, and stylesheets.
  • The <example>-[ear|ejb]/src/main/resources directory contains deployment descriptors, and other configuration files.
  • The <example>-ejb/src/main/java directory contains the application source code.

Note

Seam examples are built and run from the Maven pom.xml file, so you must have at least version 3.x of Maven installed before you get started.

3.1.1. Running the examples on Red Hat JBoss Enterprise Application Platform

Seam examples are configured for use on JBoss Enterprise Application Platform.
Set JBOSS_HOME as the environment variable. Start the application server and build examples by typing mvn install in the example's root directory. To deploy an example, change the directory to *-ear or *-web and use the command mvn jboss-as:deploy. The example gets deployed to a URL like /seam-example, where example is the name of the example folder. For instance, if JBoss Enterprise Application Platform is running on port 8080, the URL for the Registration example is http://localhost:8080/seam-registration/.
If, on the other hand, the example is packaged as a WAR, then it deploys to a URL like /${name}-web.

Note

Examples like groovybooking, hibernate, jpa, and spring can only be deployed as a WAR.

3.1.2. Running the example tests

Most examples come with a suite of JUnit and Arquillian integration tests. The easiest way to run the tests is to run the command mvn verify -Darquillian=jbossas-managed-7.