Thursday Sep 18, 2008

RichFaces & Maven - easy setup!

The last days I read a lot about RichFaces and saw this cool live demo. RichFaces sparks my interest. As the JSF Framework RichFaces from JBoss supports much more components as other frameworks and also really cool Ajax features, I started to build my first jee web module using RichFaces.
First I read this quick guide which shows how to build a JEE Webmodul using RichFaces in general. But as I planed to integrate my first example into an existing JEE project build on maven I search a lot to find out how to setup a Maven Web module with RichFaces Support.

Here is my personal quick guide to setup a maven web app with RichFaces:

1.) Add the JBoss Maven repository to your Maven Installation:

first you need to add the following repository description into your setup.xml file located in your Maven root directory:

 	<!-- JBoss RichFaces Repository -->
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>repository.jboss.com</id>
<name>Jboss Repository for Maven</name>
<url>
http://repository.jboss.com/maven2/
</url>
<layout>default</layout>
</repository>
</repositories>

So later maven will be able to download the necessary components. (I don't know why this framework is not included into the standard maven repository)

2.) Add the RichFaces Dependencies

the next (and final) step is to add the RichFaces Dependencies into your Maven Web Module (I assume that you know how to build a web module with maven).
To find out the right dependencies takes me the most time as I did not found an example on the JBoss RichFaces Homepage. But finally I found these dependency configuration which works fine:

   <dependencies>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>3.2.1.GA</version>
</dependency>
</dependencies>

So add these three dependencies into your pom.xml.

That's really all!

I completed my first integration test with the Simple Ajax Echo example at it works perfect !

Now I begin to love RichFaces :-)

Saturday Jun 28, 2008

Maven: How to exclude EJB jars from a War Module

It happened to me that when I build my multi-module maven project and deploy it to my glassfish server I receifed server errors like this:

[#|2008-06-28T23:26:31.815+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|
_ThreadID=14;
_ThreadName=Timer-7;_RequestID=dffabadc-2951-492d-9b98-88ada568fd33;
|Annotations processing failed for
/opt/glassfish/domains/domain1/applications/j2ee-apps/org.imixs.shareyourwork.ear-0.7.3/
org.imixs.shareyourwork.ejb-0.7.3_jar|#]
[#|2008-06-28T23:26:32.218+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|
_ThreadID=14;_ThreadName=Timer-7;_RequestID=dffabadc-2951-492d-9b98-88ada568fd33;
|Class org.imixs.workflow.jee.ejb.WorkflowServiceManagerImplementation is annotated with
@WebService and @Stateless but is packaged in a WAR. If it is supposed to be an EJB endpoint,
it should be packaged in a JAR; Deployment will continue assuming this class to be just a POJO
used by other classes in the WAR being deployed symbol: javax.jws.WebService

 This happens because the EJB modules which are included using a dependency tag in my war module are also added into the WEB-INF/lib directory.

And this is not allowed or necessary because the EJB jars are available in the EAR / EJB modul.

So the solution to avoid this error message was to add the folling tag to the dependency tag of the war module:

<scope>provided</scope>    

This means that the JARs of this dependency are not included into the /lib folder of the war module. So the deployment process will proceed without error messages.