Friday, August 8, 2008

Seam and Maven

A while back I mentioned that I'd post a Maven project that would make building Seam applications with Maven a little easier. Here it is, I've got three projects actually. For the impatient, you can see all the projects over here on Google code. The three projects I created are:
  1. basic-settings, this is a parent pom project to define the JBoss repository, set your compiler to Java SE 5 (Maven defaults to Java SE 1.3), and sets some defaults for the Maven eclipse plugin.
  2. seam-dependencies this project defines all your Seam dependencies. You will use this as a dependency in your Seam project. This defines the Hibernate and Seam JARs you need to get your Seam application working.
  3. seam-example this is a sample application that uses both basic-settings and seam-dependencies, to illustrate how to put it all together. This application is a simplified version of the JPA-booking example that comes with Seam.
These projects do not use Java EE in any way, so there isn't even a JBoss embedded dependency. My reason for doing this was to make building and deploying an application as easy as possible. To get to the projects, you need to download the the source from my Google code project, which you can find here, once at the project page, click the "Project" tab and that will tell you how to check out the code. Now that you've got the code checked out, run mvn install for these projects:
  1. basic-settings
  2. seam-dependencies
With everything installed, you can try out the seam-example project. To run the project, use the Maven Jetty plugin, like this:
cd seam-example
mvn jetty:run
You can access the app from port 9090, using this URL: http://localhost:9090/seam-example I also did a Seam presentation at the July 2008 UJUG meeting. You can see the presentation here.

10 comments:

Eugene Kuleshov said...

Why not create an archetype instead?

Chris Maki said...

Hi Eugene

Good question, I'm hoping to release an archetype in a couple of days. My reason for not doing this as an archetype was two fold, first the seam-dependencies project allows you to create an app however you'd like, it just brings in all the Seam "stuff". Second, I was using the project as an example on how to build a Seam app. I've found an archetype isn't always that useful for showing how something works, but is good for just using something.

Good to hear from you again :-)

Chris

Kelly said...

Quick question: I notice that a couple of these POMs have a prerequisite for Maven 2.0.9. I commented it out (didn't want to upgrade from 2.0.8) and didn't notice any hiccups. Just curious mostly...

Chris Maki said...

Hi Kelly

I made 2.0.9 the prerequisite because of how it resolves dependencies, it uses a slightly modified algorithm from Maven 2.0.8. Since I was running 2.0.9 and I didn't know if all the dependencies would resolve the same in 2.0.8 I added the prerequisite. I've heard from a few other folks who also dropped the prereq and as far as I know it's working well for them too.

Goutham said...

Hello Chris,

Did you use any tools at all for desiging the UI?

Thanks,
Goutham

Chris Maki said...

Hi Goutham

I didn't use any tools to create the UI. For this app, I used the Seam booking example to get me started. Any good HTML tool could be used however, at least to get the general setup, e.g. structure and CSS, etc.

I hope the post was helpful.

Chris

gauti said...

Thanks Chris,

We are currently working on a open source project and we wish to use Seam with icefaces there. And your example has given me lot of insight into how I could go about designing my project.
Thanks for the example again.

Cheers,
Goutham

Chris Maki said...

Hi Goutham

Thanks, I hope it gets you going in the right direction.

TTYL

Chris

rmn190 said...
This comment has been removed by the author.
rmn190 said...

Failed to execute goal on project seam-example: Could not resolve dependencies for project org.maki.seam:seam-example:war:1.0-SNAPSHOT: Failed to collect dependencies for [org.maki.seam:seam-dependencies:pom:1.0-SNAPSHOT (compile), org.testng:testng:jar:jdk15:5.8 (test), javax.el:el-api:jar:1.0 (provided), c3p0:c3p0:jar:0.9.1.2 (compile), hsqldb:hsqldb:jar:1.8.0.7 (compile), commons-lang:commons-lang:jar:2.4 (compile)]: Failed to read artifact descriptor for org.jboss.seam:jboss-seam:jar:2.0.2.SP1: Could not transfer artifact org.jboss.seam:jboss-seam:pom:2.0.2.SP1 from/to jboss-repo (http://repository.jboss.com/maven2/): Access denied to: http://repository.jboss.com/maven2/org/jboss/seam/jboss-seam/2.0.2.SP1/jboss-seam-2.0.2.SP1.pom , ReasonPhrase:Forbidden. ->


how could I resolve the problem?