Developing seam applications with woodstock and glassfish using netbeans 6
Seam is an application framework developed by JBOSS for developing next gen enterprise level applications using technologies like EJB3, JSF, portlets and Ajax. This blog entry explains how to get started with building a basic seam application with woodstock and deploy it on glassfish.Here is the source of the project i used as the reference for writing this blog entry. Remember that you would need to create the libraries i specified and resolve the project dependencies.
The first step is to create libraries for dependent jars that we will be using in our application. You would need to download seam from JBOSS website. You can download the latest version 2.0.0 GA here from JBOSS site.
Creating dependent libraries
Create the following libraries in your netbeans application. You should find most of them in the JBOSS seam archive that you downloaded.
Hibernate
- hibernate-all.jar
JBossSeam
- jboss-seam.jar
Seam-lib
- jboss-el.jar
- jboss-seam-debug.jar
- jboss-seam-ui.jar
Misc
- thirdparty-all.jar
- dom4j.jar
- persistence-api.jar
- jboss-common-core.jar
- jboss-archive-browsing.jar
Facelets
To get the facelet jars, you can install the facelets plugin for netbeans from here.
- jsf-facelets.jar
- el-api.jar
- el-ri.jar
And of course the WebuiLibrary
WebuiLibrary
- commons-beanutils.jar
- commons-collections.jar
- commons-logging.jar
- commons-digester.jar
- dataprovider.jar
- dojo-1.0.0.jar
- jhall.jar
- jsf-extensions-common-0.1.jar
- jsf-extensions-dynamic-faces-0.1.jar
- json-2.jar
- jsr311-api.jar
- prototype-1.5.0.jar
- webui-jsf.jar
- webui-jsf-suntheme.jar
The best way to get hold of these libraries would be to probably download the example app found in the woodstock website and get the jar references from there.
Creating a Seam Application
To get started off, open netbeans,
File -> New Project -> Enterprise -> Enterprise Application -> Next
Keep your target reference server as Glassfish V2 and give your project a name.
Here is how my "WoodstockExample" application comes up.

Resolving references
The next step involved is including the appropriate dependent jars for the project.
For the main project, WoodstockExample, here is how my packaging looks like.

Next for the WoodstockExample-ejb project, the libraries included are shown below.

And similarly for the Woodstock-war project.

Configuring your project
The next step is configuring your project with the appropriate resource files.
WoodstockExample/src/conf/application.xml
First, in your WoodstockExample project, create an application.xml. This looks like this. It specifies my context root and the ejb jars used.
WoodstockExample-ejb/src/conf/ejb-jar.xml
Specify the following in your ejb-jar.xml
WoodstockExample-ejb/src/conf/persistence.xml
This defines the database properties that you will be using for this application.
Give the persistence unit a name, select the persistence provider as hibernate and the table generate strategy as "drop and create"
Here is how my xml looks like.
WoodstockExample-ejb/src/conf/seam.properties
This is a blank file needed for seam. Nothing is required here.
Leave this blank.
WoodstockExample-war/src/conf/faces-config.xml
Your standard managed bean mappings go here. But since, in seam, you use annotations, you probably wont be specifying any managed beans over here.
If you use facelets (which i did in my application) you would need to specify the following in your faces-config.xml
WoodstockExample-war/src/conf/web.xml
And finally we need our standard web.xml where we need to specify a number of things.
The ejb jndi pattern, JSF and theme servlet mapping and the seam listener mappings are done here.
Here is how my web.xml looks like.
Creating the actual application
Great. Now that we have everything set, all we have left is to create the actual application. The sample application that i have is a simple registration application where you enter your user name and password and the next page shows a list box containing a list of user names and passwords. Pretty novice.
Here is what my final deployed app looked like:

You can get the source of the project here.
Note that it is a netbeans 6 project and requires glassfish.
Deploying the application
The important point to note while deploying this application on glassfish is that, you cannot right click and autodeploy the applicaton as you would do for a normal "war" file. When i tried to do this for the "ear" file, i always saw an exception being thrown by glassfish. You would need to go the admin console by typing http://localhost:4848 (or whatever your configured port number is) and manually upload the ear file.
References
Here are some blogs/ websites that helped me a lot while writing up this blog entry.
- Brian Leonard's blog - Running JBoss's seam on glassfish (a bit outdated but very helpful)
- CoffeeCrew site - Facelets, seam,, netbeans and glassfish.
- Michael Yuan's blog - Seam demo app for glassfish.
- JBoss Seam forum - A lot of great people who help out beginners like me.


I noticed there are parts of text and other stuff in the background in some of your screenshots. If you select a window and hit 'Alt+Print Screen' it will only grab that window and put the contents in the clipboard.
Posted by Erik T. Törnqvist on November 19, 2007 at 06:21 PM IST #
Thanks Erik. I have fixed this.
Posted by Venky on November 19, 2007 at 07:11 PM IST #
Hi, Whenever, i try to run this application, my glassfish server declare the WoodstockExample-ejb.jar a invalid ejb. I don't know, what am i doing wrong. This is what i get, when i run this application:
Deploying application in domain failed; Error loading deployment descriptors for module [WoodstockExample] -- Invalid ejb jar [WoodstockExample-ejb.jar]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven), please check server.log to see whether the annotations were processed properly.
Deployment error:
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:163)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor461.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:157)
... 16 more
BUILD FAILED (total time: 40 seconds)
Posted by Omar on November 22, 2007 at 07:00 AM IST #
Please make sure that you dont right click and deploy the application in netbeans. You need to manually go to the admin gui console of glassfish in the web browser and then deploy the application on to glassfish. Otherwise glassfish has some problems deploying these kind of ear files.
Posted by Venky on November 22, 2007 at 02:44 PM IST #
Also, make sure that your ear file is created properly. In the sense go to WoodStockExample/nbproject/private and check whether the path to jar files and class files are referred to appropriately. Since the application i uploaded includes my own private.properties, these have to be properly modified.
Posted by Venky on November 22, 2007 at 02:48 PM IST #
I find the website JGuru dot com very useful for stuff related to your article. You should try reading there as well.
-HA
Posted by Survey Software on December 04, 2007 at 10:38 AM IST #
you have to create at least one ejb . if you create an empty session bean it will be deployed successfully. you try to deploy null ejb archive.
Posted by ömür yavuz on December 11, 2007 at 03:11 PM IST #
AAAA
Posted by 196.203.53.218 on April 10, 2008 at 02:56 PM IST #