Deploying a seam-gen project to GlassFish

October 03, 2008

seam-gen creates projects that deploy to JBoss AS out of the box. However, a Seam application can run on any Java EE application server or servlet container with the proper packaging. I have created a page on the Seam in Action wiki that provides instructions for how to modify the build script of a seam-gen WAR project to support deployment to GlassFish (in addition to JBoss AS), as I promised I would do in Seam in Action. Unfortunately, the configuration on applies to WAR projects at this time, though it's certainly possible to deploy seam-gen EAR projects to GlassFish. It's just a matter of putting the files in the right place and I haven't yet committed the time to finding the right build configuration. Keep an eye out for updates as I will likely update the instructions when I nail it down.

Before you run off to discover how to modify your build, I want to mention a couple of things about GlassFish. It's fairly well-known amongst my colleagues and readers of my book that I like GlassFish, and I have cited those reasons in the appendix of Seam in Action. But there is a specific reason that I like GlassFish as it pertains to the build configuration I set forth on the wiki page.

GlassFish has a very sexy administrative console, but it also has a very sexy commandline tool known as asadmin. The asadmin tool gives you virtually unbounded control over the application server, including core tasks such as starting and stopping the application server, deploying and undeploying applications, and setting up database connection pools, amidst a plethora of other controls. You'll see that my modified seam-gen tool takes advantage of a handful of these commands. I encourage you to execute the help command to find out what else asadmin is capable of doing.

When choosing software, there is one thing that you should demand as a developer: efficiency. GlassFish gives you efficiency through automation, which is undoubtedly the most effective way to become efficient. As soon as you have to open up a configuration file, know that you are wasting time. Manual processes are not only slow, though. They are non-reproducible. As the wise authors of The Pragmatic Programmer advise, if you have to do something twice, script it. GlassFish volunteers itself to participate in a script and is the reason why I choose it as my preferred application server.

Posted at 03:45 AM in Java | Permalink Icon Permalink

7 Comments from the Peanut Gallery

1 | Posted by David Sachdev on October 03, 2008 at 10:24 AM EST

I really should shoot over my page of GlassFish related links, articles and the like. Our ported-site is about to go live on GlassFish soon, and our back-end has already been ported to it.

https://preview.foliofn.com/

Hopefully soon I will be able to start digging into your book. Its been sitting on my desk for weeks now, but the time just hasn't been there.

I'll drop an email soon, and lets plan lunch.

2 | Posted by John Clingan on October 03, 2008 at 10:33 AM EST

Congratulations on the book! Great to hear you like what we're doing with GlassFish ease-of-use. Of course, we're always looking for feedback on how we can make it better.

John Clingan GlassFish Group Product Manager

3 | Posted by Alexander Sparkowsky on October 05, 2008 at 08:03 AM EST

I totally aggree. GlassFish is a great app server.

The only thing that keeps me stick on JBoss is that I didn't find a comfortable way to develop a Seam application that can use GlassFish during develop and production time comfortably.

Unfortunately deploying a Seam EAR seems to be a hard job. I've tried to modify your WAR scripts to deploy an EAR but failed.

The main problems are that you need a different application.xml deployment descriptor and GlassFish doesn't accept real exploded ear archives. So you have to provide a real jar and war inside the exploded ear for GlassFish to accept them.

I hope you will find a way.

4 | Posted by frank on October 29, 2008 at 05:12 AM EST

Great book on Seam and i am looking forward to have it. The "In Action" series have proven to be a great book indeed. Seam framework had a sample app with GlassFish but i am hoping to see what you have on it. cheers

5 | Posted by Dan Allen on October 29, 2008 at 07:23 AM EST

@frank, thanks for the comment! I really hope you enjoy the book!

6 | Posted by yasser on January 30, 2009 at 05:00 AM EST

i was wondering ... any success deploying seamgen EAR on glassfish :) !

by the way great book Dan..

7 | Posted by Dan Allen on January 31, 2009 at 01:04 PM EST

Yes, I have! I was so psyched when I figured it out, I arranged to do a webinar on glassfish.tv to demonstrate how it's done. Glassfish.tv is a webinar channel run by Sun on Ustream. Here are links to the presentation and the slides.

As soon as I get done with the urgent JSF 2 spec changes next week, I am going to roll support for Glassfish into seam-gen. I held off adding the support because I had not yet figured out how to deploy an EAR to Glassfish. But thanks to the tips I got from this thread, I was able to figure out the trick. Thanks guys!

Got Something to Say?

Comment Form
Personal Info

Remember personal info?

Body