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:
Make sure you start JBoss AS. You can then open a browser and view your application.
If you've worked with Maven and previous versions of JBoss AS before, the steps above should be familiar. If not, please read below.
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 run.sh 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.
The jboss-maven-plugin allows you to deploy to an existing JBoss AS installation. You can find more info on the plugin at http://mojo.codehaus.org/jboss-maven-plugin/. Below is a tutorial to allow you to get started quickly. Consult the documentation to learn about all the features and configuration options available.
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.
<build> <plugins> ... <!-- This snippet will already be in your POM if you used the Weld Archetype --> <!-- Configure the JBoss Maven deploy plugin --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-maven-plugin</artifactId> <configuration> <!-- Link the plugin to your local install via OS environment variable JBOSS_HOME --> <jbossHome>${env.JBOSS_HOME}</jbossHome> <!-- Your JBoss domain (optional) --> <serverName>default</serverName> </configuration> </plugin> </plugins> </build>
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:
My Computerand select
Properties.
Advancedtab and click on the button at the bottom that says
Environment Variables(pictured below)
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.
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.