Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

In order to utilize the full feature set of CDI, you'll need a Java EE 6 container. This tutorial will show you how to get started with CDI, with a little help from Weld, on JBoss AS 6.0.

At the time of writing (Dec 2009), the Java EE 6 specification was only recently finalized. As a result, there are no Java EE 6 containers that have been released in a final version that are ready for production use. However, there are milestone releases of JBoss AS 6 and GlassFish V3 that are suitable for development and prototyping.

GlassFish V3 is the Java EE 6 reference implementation (RI) and JBoss AS 6 is an implementation of the Web Profile. Both servers bundle Weld as the CDI implementation.


The procedure for running a Maven CDI application in JBoss AS 6 is extremely easy. We've even prepared a Maven archetype that targets a Java EE 6 environment, with a plugin configuration included for deploying directly to JBoss AS 6. Here are the steps involved:

  1. Download JBoss AS 6 and extract to the directory of your choice (this directory will be called JBOSS_HOME)
  2. Create a JBOSS_HOME environment variable in your OS pointing to that directory.
  3. Either generate a project using the Weld Java EE 6 archetype or add the jboss-maven-plugin config to your existing Maven project.
  4. Run mvn clean package jboss:hard-deploy to build your project and deploy it to your server.

Make sure you start JBoss AS. You can then open a browser and view your application.

In Greater Depth

If you've worked with Maven and previous versions of JBoss AS before, the steps above should be familiar. If not, please read below.

Download, Install, and Configure JBoss AS 6.0

You can download JBoss AS 6.0.0.M1 from SourceForge.

JBoss AS 6 behaves exactly like previous versions of JBoss AS. Simply extract the distribution to the directory of your choice and start the container using run.bat on Windows or on *NIX (Mac and Linux). Like previous versions, you can deploy your WAR by copying it into the hot deploy directory: $JBOSS_HOME/server/default/deploy. You can also deploy your application using your IDE or the jboss-maven-plugin. Check out JBoss Tools for an enhanced version of the JBoss AS server control.

Deploying Your Application with the JBoss Maven Plugin

The jboss-maven-plugin allows you to deploy to an existing JBoss AS installation. You can find more info on the plugin at Below is a tutorial to allow you to get started quickly. Consult the documentation to learn about all the features and configuration options available.

Add jboss-maven-plugin declaration to your project's pom.xml file

In order to enable the Maven plugin, you must add a declaration to the build section of your POM (pom.xml). If you created your application from the Weld archetypes, you can skip this step. The archetype adds the config to your POM for you.

Simply add the plugin below to your pom.xml file.

      <!-- This snippet will already be in your POM if you used the Weld Archetype -->

      <!-- Configure the JBoss Maven deploy plugin -->
            <!-- Link the plugin to your local install via OS environment variable JBOSS_HOME -->
            <!-- Your JBoss domain (optional) -->

Set JBOSS_HOME Environment Variable in Your OS

In order to use the jboss-maven-plugin from your archetype or the configuration above, you'll want to set JBOSS_HOME as an environment variable in your operating system. You would use the same procedure you would use to set JAVA_HOME.


For windows users, the steps are:

  1. Right click on My Computer and select Properties.
  2. Click to the Advanced tab and click on the button at the bottom that says Environment Variables (pictured below)
  3. Create a System property (meaning available to all users) named JBOSS_HOME and point it to the directory in which you unzipped JBoss AS.

Test It Out

Startup your container, open a command line prompt to your project, and execute:

mvn clean package jboss:hard-deploy

Your WAR will be built and deployed to your JBoss AS installation and ready to be viewed in a browser. Make sure JBoss AS has been started before visiting the application in your browser.

Coming Soon: Embedded JBoss

JBoss is actively developing a version of embedded JBoss AS that can be launched from maven without prior configuration. We're very excited about this and cannot wait to integrate it into our archetypes and documentation. Until then, you'll need to run your applications from a local container install.