Gracelets - Application Deployment SourceForge.net Logo

Tutorial - Build and Deploy your application


Building

NOTE: If you have used/downloaded the archetype before January 17th, 2010, you will need to remove that copy from your maven repository and follow the setup instructions over again.
Once you have followed the instructions found here you should be able to build your web application like so (inside the root of your web application directory, we will assume your project name is 'my-gracelets-app', your output may vary, but you need to see "BUILD SUCCESSFUL" as shown below):


C:\>mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.applications:my-gracelets-app:war:0.0.1
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1-alpha-2/maven-war-plugin-2.1-alpha-2.pom

Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1-alpha-2/maven-war-plugin-2.1-alpha-2.jar

[INFO] [resources:resources]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile]
[INFO] No sources to compile
[INFO] [resources:testResources]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\gracelets\my-gracelets-app\src\test\resources
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [surefire:test]
[INFO] No tests to run.
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.pom

Downloading: http://repo1.maven.org/maven2/org/apache/maven/shared/maven-filtering/1.0-beta-1/maven-filtering-1.0-beta-1.pom

Downloading: http://repository.jboss.com/maven2//org/codehaus/plexus/plexus-interpolation/1.2/plexus-interpolation-1.2.pom
2K downloaded (plexus-interpolation-1.2.pom)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/shared/maven-filtering/1.0-beta-1/maven-filtering-1.0-beta-1.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.jar


Downloading: http://repository.jboss.com/maven2//org/codehaus/plexus/plexus-interpolation/1.2/plexus-interpolation-1.2.jar
35K downloaded (plexus-interpolation-1.2.jar)
[INFO] [war:war]
[INFO] Packaging webapp
[INFO] Assembling webapp[my-gracelets-app] in [C:\gracelets\my-gracelets-app\target\my-gracelets-app-0.0.1]
[INFO] Processing war project
[INFO] Copying webapp resources[C:\gracelets\my-gracelets-app\src\main\webapp]
[INFO] Webapp assembled in[215 msecs]
[INFO] Building war: C:\gracelets\my-gracelets-app\target\my-gracelets-app-0.0.1.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Sun Jan 17 20:27:47 MST 2010
[INFO] Final Memory: 9M/17M
[INFO] ------------------------------------------------------------------------

Deployment

In general your web application container, whether that be Tomcat standalone, JBoss or any other will need to have the SLF4J facade libraries along with the implementation of your choice installed in the main class path. You can learn more about this here and you can download the slf4j API and various implementations here.

Gracelets was developed using the 1.5.8 version of the slf4j-api, but it should work fine with later versions. For instance with JBoss Application Server you will need to copy the slf4j-api-1.x.x.jar and the implementation that corresponds to your setup. For instance JBoss 4.3.x uses log4j. There is a log4j <-> slf4j integration library that comes with the download. You will need to put both jars in the lib/ directory of the JBoss configuration you are using.

Once you have the slf4j libraries installed you need to be aware of the different environments that containers provide. For instance with JBoss it already provides the JSF API and RI implementations for applications using JSF. On the other hand, containers like Tomcat standalone normally will require you to have the API and implementation you are using in your web application lib/ directory.

Tomcat Standalone

You will need to make two basic modifications to your web application for deployment to tomcat standalone. You will need to add the JSF implementation of your choice (for instance for the JSF RI, you could add the following maven runtime dependency: javax.faces:jsf-impl:1.2_13) and change the javax.faces:jsf-api dependency to 'runtime' instead of 'provided'. Your pom.xml for your web application should like something like the following after the above said changes:

Tomcat Standalone Gracelets WAR Example pom.xml
Toggle Line Numbers
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
2   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
3   <modelVersion>4.0.0</modelVersion> 
4   <groupId>com.applications</groupId> 
5   <artifactId>my-gracelets-app</artifactId> 
6   <packaging>war</packaging> 
7   <version>0.0.1</version> 
8   <repositories> 
9     <repository> 
10         <id>jboss-maven2</id> 
11         <name>JBoss Maven 2 Repository</name> 
12         <url>http://repository.jboss.com/maven2/</url> 
13     </repository> 
14     <repository> 
15         <id>java.net-maven2</id> 
16         <name>Java.Net Maven 2 Repository</name> 
17         <url>https://maven-repository.dev.java.net/nonav/repository/</url> 
18     </repository> 
19     <repository> 
20         <id>gracelets-maven2</id> 
21         <name>Gracelets Maven 2 Repository</name> 
22         <url>http://master.dl.sourceforge.net/project/gracelets/</url> 
23     </repository> 
24     <repository> 
25         <id>javautil-maven2</id> 
26         <name>Java Util Maven 2 Repository</name> 
27         <url>http://master.dl.sourceforge.net/project/javautil/</url> 
28     </repository> 
29   </repositories> 
30   <dependencies> 
31     <dependency> 
32       <groupId>junit</groupId> 
33       <artifactId>junit</artifactId> 
34       <version>3.8.1</version> 
35       <scope>test</scope> 
36     </dependency> 
37     <dependency> 
38         <groupId>net.sourceforge.gracelets</groupId> 
39         <artifactId>gracelets-api</artifactId> 
40         <version>2.0.2.2</version> 
41     </dependency> 
42     <dependency> 
43         <groupId>net.sourceforge.gracelets</groupId> 
44         <artifactId>gracelets-impl</artifactId> 
45         <version>2.0.0.SP2</version> 
46     </dependency> 
47     <dependency> 
48         <groupId>org.codehaus.groovy</groupId> 
49         <artifactId>groovy-all</artifactId> 
50         <version>1.6.5</version> 
51         <type>jar</type> 
52         <scope>compile</scope> 
53     </dependency> 
54     <dependency> 
55         <groupId>org.slf4j</groupId> 
56         <artifactId>slf4j-api</artifactId> 
57         <version>1.5.8</version> 
58         <type>jar</type> 
59         <scope>provided</scope> 
60     </dependency> 
61     <dependency> 
62         <groupId>javax.faces</groupId> 
63         <artifactId>jsf-api</artifactId> 
64         <version>1.2_13</version> 
65     </dependency> 
66     <dependency> 
67         <groupId>javax.faces</groupId> 
68         <artifactId>jsf-impl</artifactId> 
69         <version>1.2_13</version> 
70     </dependency> 
71   </dependencies> 
72 </project> 
Tomcat standalone currently does not provide special support for JSF applications like JBoss Application Server, so you need to add the following to your web.xml:

Tomcat Standalone Gracelets WAR web.xml addition
Toggle Line Numbers
1 <listener>com.sun.faces.config.ConfigureListener</listener> 
After the previous modifications you should be able to successfully deploy the generated war file to your tomcat standalone installation.

JBoss Configuration

There should be no extra configuration when deploying the generated war file to your JBoss installation.