{:toc}
The quickstarts included in this distribution were written to demonstrate Java EE 6 and a few additional technologies. They provide small, specific, working examples that can used as a reference for your own project.
These quickstarts will run in both the JBoss AS 7 or the JBoss Enterprise Application Platform 6 environments. If you want to run the quickstarts in JBoss Enterprise Application Platform 6, we recommend using the JBoss Enterprise Application Platform zip file. This version uses the correct dependencies and ensures you test and compile against your runtime environment.
Be sure to read this entire document before you attempt to work with the quickstarts. It contains the following information:
-
Available Quickstarts: List of the available quickstarts and details about each one.
-
System Requirements: List of software required to run the quickstarts.
-
Maven Configuration: Configure the Maven repository for use by the quickstarts.
-
How to Build and Deploy the Quickstarts: General instructions for building and deploying the quickstarts.
-
How to Approach the Quickstarts: Suggested Approach on how to start with the quickstarts.
-
Install and Configure the PostgreSQL Database: Install and configure the Postgresql database for quickstarts that need it.
The following is the current list of quickstarts, the technologies they demonstrate, the level of experience required, and other quickstarts that may be a prerequisite to understanding and running the quickstart. Quickstarts with tutorials in the Getting Started Developing Applications Guide are noted with two asterisks ( ** ) following the quickstart name.
Quickstart Name | Demonstrated Technologies | Description | Experience Level Required | Prerequisites to This Quickstart |
---|---|---|---|---|
bean-validation | Bean Validation, JPA | Example that uses JBA and does bean validation. | Beginner | None |
bmt | EJB, BMT | EJB that demonstrates bean-managed transactions (BMT) | Beginner | None |
cdi-injection | CDI injection, Qualifiers, Servlet | TBD | Beginner | None |
cmt | EJB, container-managed transaction (CMT) | EJB that demonstrates container-managed transactions (CMT) | Beginner | None |
ejb-in-ear | EJB, JSF, JAR, and WAR deployed as an EAR | TBD | Beginner | None |
ejb-in-war | EJB and JSF deployed as a WAR | TBD | Beginner | None |
ejb-remote | Remote EJB | TBD | Beginner | None |
forge-from-scratch | Forge | TBD | Beginner | None |
greeter | CDI, JSF, JPA, EJB, JTA | TBD | Beginner | None |
h2-console | H2 Database Console | TBD | Beginner | None |
helloworld** | Basic CDI, Servlet | Basic example that can be used to verify that the server is configured and running correctly. | Beginner | None |
helloworld-gwt | GWT | TBD | Beginner | None |
helloworld-html5 | Basic HTML5 | TBD | Beginner | None |
helloworld-jms | JMS | TBD | Intermediate | None |
helloworld-jsf | Basic CDI, JSF | TBD | Beginner | None |
helloworld-mdb | Basic JMS, message-driven bean (MDB) | TBD | Intermediate | None |
helloworld-osgi** | OSGi JAR | TBD | Beginner | None |
helloworld-rs | CDI, JAX-RS | Intermediate | None | |
helloworld-singleton | Singleton Session Bean | TBD | Beginner | None |
hibernate 3 | Hibernate 3 | Uses Hibernate version 3 for database access. Compare the code in this quickstart to the code in hibernate4 to see the changes you must make to move to Hibernate 4 | Beginner | None |
hibernate 4 | Hibernate 4 | This quickstart performs the same functions as hibernate3 quickstart, but uses Hibernate version 4 for database access. Compare the quickstarts to see the differences. | Beginner | None |
jts | JTS | Uses Java Transaction Service (JTS) to coordinate distributed transactions | Intermediate | None |
kitchensink** | CDI, JSF, JPA, EJB, JPA, JAX-RS, BV | A good example that incorporates multiple technologies | Beginner | None |
kitchensink-ear | EAR | Based on the kitchensink quickstart, but deployed as an EAR. | Beginner | None |
kitchensink-html5-mobile | HTML5 | Based on kitchensink, but uses HTML5, making it suitable for mobile and tablet computers. | Beginner | None |
kitchensink-jsp | JSP | Based on kitchensink, but uses a JSP for the user interface. | Beginner | None |
log4j | JBoss Modules | Demonstrates how to use modules to control class loading for 3rd party logging frameworks. | Beginner | None |
numberguess** | CDI, JSF | TBD | Beginner | None |
payment-cdi-event | CDI, Events | TBD | Beginner | None |
servlet-async | CDI, EJB, Servlet | Demonstrates CDI, plus asynchronous Servlets and EJBs. | Intermediate | None |
servlet-filter | Servlet | Demonstrates Servlet filters and listeners. | Intermediate | None |
To run these quickstarts with the provided build scripts, you will need the following:
-
Java 1.6, to run JBoss AS and Maven. You can choose from the following: * OpenJDK * Oracle Java SE * Oracle JRockit
-
Maven 3.0.0 or newer, to build and deploy the examples * Follow the official Maven installation guide if you don't already have Maven 3 installed. * If you have Maven installed, you can check the version by running this command in a shell prompt:
mvn --version
-
The JBoss AS 7 distribution zip or the JBoss Enterprise Application Platform 6 distribution zip * For information on how to install and run JBoss, refer to the product documentation.
-
You can also deploy the quickstarts from Eclipse using JBoss tools. For more information on how to set up Maven and the JBoss tools, refer to the Getting Started Developing Applications Guide.
Maven configuration is dependent on whether you are running JBoss AS7 or JBoss Enterprise Application Platform 6.
If you are using the JBoss AS 7 Quickstart distribution, the community artifacts are available in the Maven central repository so no additional configuration is needed.
If you are using the JBoss Enterprise Application Platform 6 distribution, you will need to download and configure the Maven repository.
-
Download the JBoss Enterprise Application Platform 6 Maven repository distribution zip and unzip it into a directory of your choice.
-
Modify the example-settings.xml file located in the root of your quickstarts folder. Replace all instances of 'path/to/jboss-eap/repo' within '<url>file:///path/to/jboss-eap/repo</url>' with the fully qualified path to the Maven repository you unzipped in the previous step.
-
When you run Maven commands, you will need to append '-s PathToQuickstarts/example-settings.xml' to the command, for example:
mvn jboss-as:deploy -s PathToQuickstarts/example-settings.xml
-
You can configure the Maven user settings if you do not want to add the alternate path parameter each time you issue a Maven command. * If you have an existing ~/.m2/settings.xml file, modify it with the configuration information from the example-settings.xml file. * If there is no ~/.m2/settings.xml file, copy the example-settings.xml file to the ~/.m2 directory and rename it to settings.xml.
To run the quickstarts, in most cases you do the following:
a. Open a shell prompt and navigate to the root of the JBoss directory.
b. For most of the quickstarts, you run the standalone script located in
the JBoss server /bin/ folder with no arguments. The following shows the
command line to start the JBoss AS 7 or Enterprise Application
Platform 6 Server.
<blockquote>
<table border="1">
<tr>
<th>Operating System</th>
<th>Command line to Start the Server</th>
</tr>
<tr>
<td>Linux</td>
<td>JBOSS_HOME/bin/standalone.sh</td>
</tr>
<tr>
<td>Windows</td>
<td>JBOSS_HOMEHOME/bin/standalone.bat</td>
</tr>
</table>
</blockquote>
c. Some quickstarts use subsystems or services included only in the full
profile. By default, the JBoss Enterprise Application Platform 6
standalone configuration contains the full profile, so you start the
server with the same command line as above. No argument is required.
However, in JBoss AS 7, the default configuration defines minimal
subsystems and services, so you need to add a parameter to the command
line when you start the server. The following shows the command line
to start JBoss AS 7 with the full profile.
<blockquote>
<table border="1">
<tr>
<th>Operating System</th>
<th>Command line to Start the Server with a full profile</th>
</tr>
<tr>
<td>Linux</td>
<td>JBOSS_HOME/bin/standalone.sh -c standalone-full.xml</td>
</tr>
<tr>
<td>Windows</td>
<td>JBOSS_HOME/bin/standalone.bat -c standalone-full.xml</td>
</tr>
</table>
</blockquote>
d. Some quickstarts require custom configuration and require command line
arguments. If a command line argument is required, the quickstart README will
provide specific instructions.
- Build and deploy the quickstarts
* Open a shell prompt and navigate to the root of the directory of the
quickstart you want to run.
* Build the archive
- The command used to build the quickstart will depend on the individual quickstart, the server version, and how you configured Maven.
- If you are running JBoss AS 7, it uses community artifacts available in the Maven central repository, so command line arguments are not usually required.
- If you are running JBoss Enterprise Application Platform 6 and did not
configure the Maven user settings described in in step 4 in
Maven Configuration for JBoss Enterprise Application Platform 6
above, you will need to specify command line arguments. - Although some of the quickstarts require special commands, for most of the quickstarts you will do the following.
Server Version Command to build quickstart JBoss AS 7 mvn clean package JBoss Enterprise Application Platform 6, Maven user settings configured mvn clean package JBoss Enterprise Application Platform 6, Maven user settings NOT configured mvn clean package -s _PathToQuickstarts_/example-settings.xml
* Deploy the archive
* Deploy the archive built in the previous step by typing the following in the command line:
<blockquote><i>mvn jboss-as:deploy</i></blockquote?
* Build and deploy the quickstart in one step
* The command you issue to build and deploy the quickstart also depend
on the individual quickstart, the server version, and how you configured
Maven.
* As mentioned above, if you are running JBoss Enterprise Application
Platform 6 and did not configure the Maven user settings described in in step 4 of
<a href="eap6mavenconfig">Maven Configuration for JBoss Enterprise Application Platform 6</a>
above, you will need to specify command line arguments.
* Although some of the
quickstarts require special commands, for most of the quickstarts
you will do the following.
<blockquote>
<table border="1">
<col width="30%"/>
<col width="70%"/>
<tr>
<th>Server Version</th>
<th>Command to build and deploy the quickstart</th>
</tr>
<tr>
<td>JBoss AS 7</td>
<td>mvn package jboss-as:deploy</td>
</tr>
<tr>
<td>JBoss Enterprise Application Platform 6, Maven user settings configured</td>
<td>mvn package jboss-as:deploy</td>
</tr>
<tr>
<td>JBoss Enterprise Application Platform 6, Maven user settings NOT configured</td>
<td>mvn package jboss-as:deploy -s _PathToQuickstarts_/example-settings.xml</td>
</tr>
</table>
</blockquote>
* The command to undeploy the quickstart is simply:
<blockquote><i>mvn jboss-as:undeploy</i></blockquote>
- See the README file in the individual quickstart folder for specific details and information on how to run and access the example.
- You can also start JBoss AS 7 and deploy the quickstarts using Eclipse. See the Getting Started Developing Applications Guide for more information.
We suggest you approach the quickstarts as follows
- Regardless of your level of expertise, we suggest you start with the helloworld example. It is the simplest example and is an easy way to prove your server is configured and start correctly
- If you are a beginner or new to JBoss, start with the quickstarts labeled Beginner, then try the Intermediate. When you're comfortable with those, move on to the Advanced.
- Some quickstarts are based on other quickstarts, but have expanded capabilities and functionality. If a prerequisite quickstart is listed, be sure to run through it before looking at the expanded version.
- TODO: complete this section
Some of the quickstarts require the PostgreSQL database. This section describes how to install and configure the database for use with the quickstarts.
Use the following steps to install and configure PostgreSQL on Linux:
- Install PostgreSQL
- The yum install instructions for PostgreSQL can be found here: http://yum.postgresql.org/howtoyum.php/
- Download the repository RPM from here: http://yum.postgresql.org/repopackages.php/
- Download the PDF installation guide fhere: http://yum.postgresql.org/files/PostgreSQL-RPM-Installation-PGDG.pdf
- To install PostgreSQL, in a shell prompt type:
sudo rpm -ivh pgdg-fedora91-9.1-4.noarch.rpm
- See the "important note" on http://yum.postgresql.org/howtoyum.php/ for details on how to exclude postgresql packages from the repository of the distribution.
- Install postgresql91 and postgres91-server by typing the following in a shell prompt:
sudo yum install postgresql91 postgresql91-server
- Set a password for the postgres user
- In a shell prompt, login as root and set the postgres password by typing the following commands:
su passwd postgres
- Choose a password
- Configure the test database
- In a shell prompt, login as the postgres user, navigate to the postgres directory, and initialize the database by typing:
su postgres cd /usr/pgsql-9.1/bin/ ./initdb -D /var/lib/pgsql/9.1/data
- Modify the /var/lib/pgsql/9.1/data/pg_hba.conf file to set the authentication scheme to password for tcp connections.
Modify the line following the IPv4 local connections: change trust to to password. The line should look like this;
host all all 127.0.0.1/32 password
- Mofify the /var/lib/pgsql/9.1/data/postgresql.conf file to allow prepared transactions and reduce the maximum number of connections.
max\_prepared\_transactions = 10 max\_connections = 10
- Start the database server.
- In the same shell prompt, type the following:
./postgres -D /var/lib/pgsql/9.1/data
- Note, this command will not release the shell prompt. In the next step you weill new to open a new shell prompt.
- Create the test1 database
- Open a new shell prompt and login again as the postgres user, navigate to the postgres directory, and create the test1 database by typing the following:
su postgres cd /usr/pgsql-9.1/bin/ ./createdb test1
Use the following steps to install and configure PostgreSQL on Windows:
- Install PostgreSQL
- Download the PostgreSQL install from here; http://www.postgresql.org/download/windows/
- Install PostgesQL using the Windows installer
- Enable password authentication and configure PostgreSQL to allow prepared transactions:
- Modify the C:\Program Files\PostgreSQL\9.1\data\pg_hba.conf file o set the authentication scheme to password for tcp connections
Modify the line following the IPv4 local connections: change trust to to password. The line should look like this;
host all all 127.0.0.1/32 password
- Modify the C:\Program Files\PostgreSQL\9.1\data\postgresql.conf file to allow prepared transactions and reduce the maximum number of connections.
max\_prepared\_transactions = 10 max\_connections = 10
- Start the database server.
- Choose Start -> All Programs -> PostgreSQL 9.1\pgAdmin III
- Server Groups -> Servers (1) -> PostreSQL 9.1 (localhost:5432)
- Right click -> Stop Service
- Right click -> Start Service
- Create the test1 database
- Open a shell prompt
- cd C:\Program Files\PostgreSQL\9.1\bin\
- createdb.exe -U postgres test1
-
Open a shell prompt, login as the postgres user, and navigate to the postgres directory
su postgres cd /usr/pgsql-9.1/bin/
-
Start the PostgreSQL interactive terminal by typing the following command:
psql -U postgres
-
Create the user sa with password sa and all privileges on database test1 by typing the following commands:
create user sa with password 'sa'; grant all privileges on database test1 to sa;
-
Test the connection to the database using the TCP connection as user 'sa'. This will validate that the change to pg_hba.conf was made correctly:
psql -h 127.0.0.1 -U sa test1
- Create the following directory structure: JBOSS_HOME/modules/org/postgresql/main
- Download the JBDC driver from <http://jdbc.postgresql.org/download.html /> and copy it into the directory you created in the previous step.
- In the same directory, create a file named module.xml. Copy the following contents into the file:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="org.postgresql"> <resources> <resource-root path="postgresql-9.1-901.jdbc4.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
- Backup the file: JBOSS_HOME/standalone/configuration/standalone-full.xml
- Open the file in an editor and locate the subsystem "urn:jboss:domain:datasources:1.0".
- Add the following datasource configuration into the section. (note, you will need to merge the drivers section):
<xa-datasource jndi-name="java:jboss/datasources/XA" pool-name="XA" enabled="true" use-java-context="true"> <xa-datasource-property name="ServerName">localhost</xa-datasource-property> <xa-datasource-property name="DatabaseName">test1</xa-datasource-property> <xa-datasource-property name="User">sa</xa-datasource-property> <xa-datasource-property name="Password">sa</xa-datasource-property> <driver>postgresql</driver> <recovery> <recover-credential> <user-name>sa</user-name> <password>sa</password> </recover-credential> </recovery> </xa-datasource>
- Add the following driver to the <drivers> section in the same subsystem. You need to merge the drivers section:
<driver name="postgresql" module="org.postgresql"> <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> </driver>
- Add the following datasource configuration into the section. (note, you will need to merge the drivers section):