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 be used as a reference for your own project.
These quickstarts run on both JBoss Enterprise Application Platform 6 and JBoss AS 7. If you want to run the quickstarts on JBoss Enterprise Application Platform 6, we recommend using the JBoss Enterprise Application Platform 6 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.
-
Suggested Approach to the Quickstarts: A suggested approach on how to work with the quickstarts.
-
System Requirements: List of software required to run the quickstarts.
-
Configure Maven: How to configure the Maven repository for use by the quickstarts.
-
Run the Quickstarts: General instructions for building, deploying, and running the quickstarts.
-
Run the Arquillian Tests: How to run the Arquillian tests provided by some of the quickstarts.
-
Optional Components: How to install and configure optional components required by some of the quickstarts.
The following is a list of the currently available quickstarts. The table lists each quickstart name, the technologies it demonstrates, gives a brief description of the quickstart, and the level of experience required to set it up. For more detailed information about a quickstart, click on the quickstart name.
Some quickstarts are designed to enhance or extend other quickstarts. These are noted in the Prerequisites column. If a quickstart lists prerequisites, those must be installed or deployed before working with the quickstart.
Quickstarts with tutorials in the Get Started Developing Applications are noted with two asterisks ( ** ) following the quickstart name.
[TOC-quickstart]
We suggest you approach the quickstarts as follows:
- Regardless of your level of expertise, we suggest you start with the helloworld quickstart. It is the simplest example and is an easy way to prove your server is configured and started correctly.
- If you are a beginner or new to JBoss, start with the quickstarts labeled Beginner, then try those marked as Intermediate. When you are comfortable with those, move on to the Advanced quickstarts.
- Some quickstarts are based upon other quickstarts but have expanded capabilities and functionality. If a prerequisite quickstart is listed, be sure to deploy and test it before looking at the expanded version.
To run these quickstarts with the provided build scripts, you 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
-
If you have not yet installed Maven, see the Maven Getting Started Guide for details.
-
If you have installed Maven, you can check the version by typing the following in a command line:
mvn --version
-
-
The JBoss Enterprise Application Platform 6 distribution ZIP or the JBoss AS 7 distribution ZIP.
- For information on how to install and run JBoss, refer to the product documentation.
-
You can also use JBoss Developer Studio or Eclipse to run the quickstarts.
Maven configuration is dependent on whether you are running JBoss Enterprise Application Platform 6 or JBoss AS7.
If you are using the JBoss Enterprise Application Platform 6 distribution, you 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
withinfile:///path/to/jboss-eap/repo
with the fully qualified path to the Maven repository you unzipped in the previous step. -
Be sure to use 3 forward slashes after
file:
: 2 for the protocol and 1 for the fully qualified path. For example:file:///home/username/Quickstarts/jboss-eap-6.0-quickstarts
-
-
Configure the Maven user settings.
-
Note:This is the recommended approach and is required if you are running the quickstarts in JBoss Developer Studio.
-
Look for the
settings.xml
file in the${user.home}/.m2/
directory. For example:For Linux or Mac: ~/.m2/settings.xml For Windows: \Documents and Settings\USER_NAME\.m2\settings.xml or \Users\USER_NAME\.m2\settings.xml
-
If you have an existing
settings.xml
file, modify it with the configuration information from theexample-settings.xml
file. -
If there is no
settings.xml
file, copy the modifiedexample-settings.xml
file to them2
directory for your operating system and rename it tosettings.xml
.
-
-
If you choose not to configure the
settings.xml
file described in the previous step, you must append-s PATH_TO_QUICKSTARTS/example-settings.xml
to every Maven command.-
Note: This only valid only when you run the quickstarts using the command line.
-
The following is an example of a deployment passing the Maven settings using the command line:
mvn jboss-as:deploy -s PATH_TO_QUICKSTARTS/example-settings.xml
-
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.
The root folder of each quickstart contains a README file with specific details on how to build and run the example. In most cases you do the following:
Before you deploy a quickstart, in most cases you need a running server. A few of the Arquillian tests do not require a running server. This will be noted in the README for that quickstart.
The JBoss server can be started a few different ways.
- Start the JBoss Server With the web profile: This is the default configuration. It defines minimal subsystems and services.
- Start the JBoss Server with the full profile: This profile configures many of the commonly used subsystems and services.
- Start the JBoss Server with a custom configuration: Custom configuration parameters can be specified on the command line when starting the server.
The README for each quickstart will specify which configuration is required to run the example.
-
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
-
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 full profile:
For Linux: JBOSS_HOME/bin/standalone.sh -c standalone-full.xml For Windows: JBOSS_HOME\bin\standalone.bat -c standalone-full.xml
-
Open a command line and navigate to the root of the JBoss server directory.
-
The following shows the command line to start the server. Replace the CUSTOM_OPTIONS with the custom optional parameters specified in the quickstart.
For Linux: JBOSS_HOME/bin/standalone.sh CUSTOM_OPTIONS For Windows: JBOSS_HOME\bin\standalone.bat CUSTOM_OPTIONS
Review the README file in the root folder of the quickstart for specific details on how to build and run the example. In most cases you do the following:
- The command used to build the quickstart depends on the individual quickstart, the server version, and how you configured Maven.
- If you are running JBoss Enterprise Application Platform 6 and did not configure the Maven user settings described in Configure Maven for JBoss Enterprise Application Platform 6 above, you need to specify command line arguments.
- 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.
- See the README file in each individual quickstart folder for specific details and information on how to run and access the example.
In some cases, you may want to build the application to test for compile errors or view the contents of the archive.
-
Open a command line and navigate to the root directory of the quickstart you want to build.
-
Use this command if you only want to build the archive, but not deploy it:
For JBoss AS 7 or JBoss Enterprise Application Platform 6 (Maven user settings configured): mvn clean package For JBoss Enterprise Application Platform 6 (Maven user settings NOT configured): mvn clean package -s PATH_TO_QUICKSTARTS/example-settings.xml
-
Make sure you start the JBoss Server as described in the README.
-
Open a command line and navigate to the root directory of the quickstart you want to run.
-
Use this command to build and deploy the archive:
For JBoss AS 7 or JBoss Enterprise Application Platform 6 (Maven user settings configured): mvn clean package jboss-as:deploy For JBoss Enterprise Application Platform 6 (Maven user settings NOT configured): mvn clean package jboss-as:deploy -s PATH_TO_QUICKSTARTS/example-settings.xml
The command to undeploy the quickstart is simply:
mvn jboss-as:undeploy
Some of the quickstarts provide Arquillian tests. By default, these tests are configured to be skipped, as Arquillian tests require the use of a container.
You can run these tests using either a remote or managed container. The quickstart README should tell you what you should expect to see in the console output and server log when you run the test.
- Test the quickstart on a Remote Server
-
A remote container requires you start the JBoss Enterprise Application Platform 6 or JBoss AS 7 server before running the test. Start the JBoss Server as described in the quickstart README file.
-
Run the test goal with the following profile activated:
For JBoss AS 7 or JBoss Enterprise Application Platform 6 (Maven user settings configured):
mvn clean test -Parq-jbossas-remote
For JBoss Enterprise Application Platform 6 (Maven user settings NOT configured):
mvn clean test -Parq-jbossas-remote -s PATH_TO_QUICKSTARTS/example-settings.xml
-
-
Test the quickstart on Managed Server
Note: This test requires that your server is not running. Arquillian will start the container for you, however, you must first let it know where to find the remote JBoss container.
-
Open the test/resources/arquillian.xml file located in the quickstart directory.
-
Find the configuration for the remote JBoss container. It should look like this:
<container qualifier="jboss" default="true"> <!-- If you want to use the JBOSS_HOME environment variable, just delete the jbossHome property --> <configuration> <property name="jbossHome">/path/to/jboss/as</property> </configuration> </container>
-
Find the "jbossHome" property and replace the "/path/to/jboss/as" value with the actual path to your JBoss Enterprise Application Platform 6 or JBoss AS 7 server.
-
Run the test goal with the following profile activated:
For JBoss Enterprise Application Platform 6 (Maven user settings NOT configured):
mvn clean test -Parq-jbossas-managed -s PATH_TO_QUICKSTARTS/example-settings.xml
For JBoss AS 7 or JBoss Enterprise Application Platform 6 (Maven user settings configured):
mvn clean test -Parq-jbossas-managed
-
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 JBoss Enterprise Application Platform 6 Development Guide or Get Started Developing Applications.
The following components are needed for only a small subset of the quickstarts. Do not install or configure them unless the quickstart requires it.
-
Add a User: Add a Management or Application user for the quickstarts that run in a secured mode.
-
Install and Configure the PostgreSQL Database: The PostgreSQL database is used for the distributed transaction quickstarts.
-
Install and Configure Byteman: This tool is used to demonstrate crash recovery for distributed transaction quickstarts.
By default, JBoss Enterprise Application Platform 6 and JBoss AS 7 are now distributed with security enabled for the management interfaces. A few of the quickstarts use these management interfaces and require that you create a management or application user to access the running application. A script is provided in the JBOSS_HOME/bin
directory for that purpose.
The following procedures describe how to add a user with the appropriate permissions to run the quickstarts that depend on them.
-
Open a command line
-
Type the command for your operating system
For Linux: JBOSS_HOME/bin/add-user.sh For Windows: JBOSS_HOME\bin\add-user.bat
-
You should see the following response:
What type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties) (a):
At the prompt, press enter to use the default Management User
-
You should see the following response:
Enter the details of the new user to add. Realm (ManagementRealm) :
If the quickstart README specifies a realm, type it here. Otherwise, press enter to use the default
ManagementRealm
. -
When prompted, enter the following
Username : admin Password : (choose a password for the admin user)
Repeat the password
-
Choose yes for the remaining promts.
-
Open a command line
-
Type the command for your operating system
For Linux: JBOSS_HOME/bin/add-user.sh For Windows: JBOSS_HOME\bin\add-user.bat
-
You should see the following response:
What type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties) (a):
At the prompt, type: b
-
You should see the following response:
Enter the details of the new user to add. Realm (ApplicationRealm) :
If the quickstart README specifies a realm, type it here. Otherwise, press enter to use the default
ApplicationRealm
. -
When prompted, enter the the Username and Passord. If the quickstart README specifies a Username nad Password, enter them here. Otherwise, use the default Username
quickstartUser
and PasswordquickstartPassword
.Username : quickstartUser Password : quickstartPassword
-
At the next prompt, you will be asked "What roles do you want this user to belong to?". If the quickstart README specifies a role to use, enter that here. Otherwise, type the role:
guest
Some of the quickstarts require the PostgreSQL database. This section describes how to install and configure the database for use with these quickstarts.
The following is a brief overview of how to install PostgreSQL. More detailed instructions for installing and starting PostgreSQL can be found on the internet.
Note: Although the database only needs to be installed once, to help partition each quickstart we recommend using a separate database per quickstart. Where you see QUICKSTART_DATABASENAME, you should replace that with the name provided in the particular quickstart's README
Use the following steps to install and configure PostgreSQL on Linux. You can download the PDF installation guide here: http://yum.postgresql.org/files/PostgreSQL-RPM-Installation-PGDG.pdf
-
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/
-
To install PostgreSQL, in a command line type:
sudo rpm -ivh pgdg-fedora91-9.1-4.noarch.rpm
-
Edit your distributions package manager definitions to exclude PostgreSQL. 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 command line:
sudo yum install postgresql91 postgresql91-server
-
-
Set a password for the postgres user
-
In a command line, 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 command line, 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
-
Modify the
/var/lib/pgsql/9.1/data/postgresql.conf
file to allow prepared transactions and reduce the maximum number of connectionsmax_prepared_transactions = 10 max_connections = 10
-
-
Start the database server
-
In the same command line, type the following:
./postgres -D /var/lib/pgsql/9.1/data
-
Note, this command does not release the command line. In the next step you need to open a new command line.
-
-
Create a database for the quickstart (as noted above, replace QUICKSTART_DATABASENAME with the name provided in the particular quickstart)
-
Open a new command line and login again as the postgres user, navigate to the postgres directory, and create the database by typing the following:
su postgres cd /usr/pgsql-9.1/bin/ ./createdb QUICKSTART_DATABASENAME
-
The following are the steps to install and start PostgreSQL on Mac OS X. Note that this guide covers only 'One click installer' option.
-
Install PostgreSQL using Mac OS X One click installer: http://www.postgresql.org/download/macosx/
-
Allow prepared transactions:
sudo su - postgres
-
Edit
/Library/PostgreSQL/9.1/data/postgresql.conf
to allow prepared transactionsmax_prepared_transactions = 10
-
-
Start the database server
cd /Library/PostgreSQL/9.1/bin ./pg_ctl -D ../data restart
-
Create a database for the quickstart (as noted above, replace QUICKSTART_DATABASENAME with the name provided in the particular quickstart)
./createdb QUICKSTART_DATABASENAME
-
Verify that everything works. As the postgres user using the password you specified in Step 1, type the following:
cd /Library/PostgreSQL/9.1/bin ./psql -U postgres
At the prompt
start transaction; select 1; prepare transaction 'foobar'; commit prepared 'foobar';
Use the following steps to install and configure PostgreSQL on Windows:
-
Install PostgreSQL using the Windows installer: http://www.postgresql.org/download/windows/
-
Enable password authentication and configure PostgreSQL to allow prepared transactions
-
Modify the
C:\Program Files\PostgreSQL\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`
-
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) -> PostgreSQL 9.1 (localhost:5432)
- Right click -> Stop Service
- Right click -> Start Service
-
Create a database for the quickstart (as noted above, replace QUICKSTART_DATABASENAME with the name provided in the particular quickstart) * Open a command line
cd C:\Program Files\PostgreSQL\9.1\bin\ createdb.exe -U postgres QUICKSTART_DATABASENAME
-
Make sure the PostgreSQL bin directory is in your PATH.
- Open a command line and change to the root directory psql
- If you see an error that 'psql' is not a recognized command, you need to add the PostgreSQL bin directory to your PATH environment variable.
-
As the postgres user, start the PostgreSQL interactive terminal by typing the following command:
psql -U postgres
-
Create the user sa with password sa and all privileges on the database by typing the following commands (as noted above, replace QUICKSTART_DATABASENAME with the name provided in the particular quickstart):
create user sa with password 'sa'; grant all privileges on database "QUICKSTART_DATABASENAME" to sa; \q
-
Test the connection to the database using the TCP connection as user
'sa'
. This validates that the change topg_hba.conf
was made correctly:psql -h 127.0.0.1 -U sa QUICKSTART_DATABASENAME
-
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>
You can configure the driver using the JBoss CLI or by manually editing the configuration file.
-
Start the JBoss Enterprise Application Platform 6 or JBoss AS 7 Server by typing the following:
For Linux: JBOSS_HOME_SERVER_1/bin/standalone.sh -c standalone-full.xml For Windows: JBOSS_HOME_SERVER_1\bin\standalone.bat -c standalone-full.xml
-
To start the JBoss CLI tool, open a new command line, navigate to the JBOSS_HOME directory, and type the following:
For Linux: bin/jboss-cli.sh --connect For Windows: bin\jboss-cli.bat --connect
-
At the prompt, type the following:
[standalone@localhost:9999 /] /subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
-
Backup the file:
JBOSS_HOME/standalone/configuration/standalone-full.xml
-
Open the
JBOSS_HOME/standalone/configuration/standalone-full.xml
file in an editor and locate the subsystemurn:jboss:domain:datasources:1.0
. -
Add the following driver to the
<drivers>
section that subsystem. You may need to merge with other drivers in that section:<driver name="postgresql" module="org.postgresql"> <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> </driver>
The installation of PostgreSQL is a one time procedure. However, unless you have set up the database to automatically start as a service, you must repeat the instructions "Start the database server" above for your operating system every time you reboot your machine.
Byteman is used by a few of the quickstarts to demonstrate distributed transaction processing and crash recovery.
Byteman is a tool which simplifies tracing and testing of Java programs. Byteman allows you to insert extra Java code into your application, either as it is loaded during JVM startup or after it has already started running. This code can be used to trace what the application is doing and to monitor and debug deployments to be sure it is operating correctly. You can also use Byteman to inject faults or synchronization code when testing your application. A few of the quickstarts use Byteman to halt an application server in the middle of a distributed transaction to demonstrate crash recovery.
-
Download Byteman from http://www.jboss.org/byteman/downloads/
-
Extract the ZIP file to a directory of your choice.
-
By default, the Byteman download provides unrestricted permissions to others which can cause a problem when running Ruby commands for the OpenShift quickstarts. To restrict the permissions to others, open a command line and type the followinge:
cd byteman-download-2.0.0/ chmod -R o-rwx byteman-download-2.0.0/
NOTE: The Byteman scripts only work in JTA mode. They do not work in JTS mode. If you have configured the server for a JTS quickstart, you must follow the instructions to Remove the JTS Configuration from the JBoss server before making the following changes. Otherwise Byteman will not halt the server.
When instructed to use Byteman to halt the application, perform the following steps:
-
Find the appropriate configuration file for your operating system in the list below.
For Linux: JBOSS_HOME/bin/standalone.conf For Windows: JBOSS_HOME\bin\standalone.conf.bat
-
Important: Make a backup copy of this file before making any modifications.
-
The quickstart README should specify the text you need to append to the server configuration file.
-
Open the configuration file and append the text specified by the quickstart to the end of the file. Make sure to replace the file paths with the correct location of your quickstarts and the Byteman download.
-
The following is an example of of the configuration changes needed for the jta-crash-rec quickstart:
For Linux, open the
JBOSS_HOME/bin/standalone.conf
file and append the following line:JAVA_OPTS="-javaagent:/PATH_TO_BYTEMAN_DOWNLOAD/lib/byteman.jar=script:/PATH_TO_QUICKSTARTS/jta-crash-rec/src/main/scripts/xa.btm ${JAVA_OPTS}"
For Windows, open the
JBOSS_HOME\bin\standalone.conf.bat
file and append the following line:SET "JAVA_OPTS=%JAVA_OPTS% -javaagent:C:PATH_TO_BYTEMAN_DOWNLOAD\lib\byteman.jar=script:C:\PATH_TO_QUICKSTARTS\jta-crash-rec\src\main\scripts\xa.btm %JAVA_OPTS%"
When you are done testing the quickstart, remember to restore the configuration file with the backup copy you made in step 2 above.