Monday Nov 19, 2007

This short write up explains how to use seam framework with woodstock and develop an application using netbeans 6.0 IDE and deploy it on glassfish. 

[Read More]

Sunday Oct 21, 2007

I have been playing around with seam and woodstock. One of the things i wanted to do was run seam on glassfish. Glassfish is one of the first containers to be JavaEE 5 compliant and IMO its neat.. . The best JavaEE containers that you can find in the market today.(I have nothing against the JBoss container.. but it just doesnt appeal
to me.. glassfish seems much more faster and simpler to use) And of course i dont think i need to say much about woodstock.. I have already blogged a lot about it :-)

Being a complete newbie.. the first thing i intended to do was start out with seam. This blog entry describes what i did. (sort of an idiot's guide to installing seam).

The next thing was to pick out the simplest of examples that seam provides you and port it to glassfish. The seam installation, does provide a default glassfish compliant application(hotel booking) that you can deploy and try it out.. But whats the fun in using something thats already given to me ready made.. The simplest that i could find was the registration example. This blog from Michael Yuan single handedly made my transition from JBoss container to glassfish completely painless.. You could also refer to Roger Kitan's and Brian Leonard's blogs.

You can take a look at Michael Yuan's blog to see how to port the application to glassfish. Since its all mentioned there clearly, i dont want to mention them here again. It mostly involves including some jars and making property file changes. (and of course using hibernate JPA instead of toplink essentials)

The only extra thing i needed to do was to have a mandatory import.sql file which inserted some dummy users into the data base.

The next thing to be done was to port the application to use woodstock components in the application instead of the JSF RI components. I am not a master with facelets and i didnt want to spend time right now to configure woodstock to use facelets.(hmmm.. sometime later.. not now..)
So, the next simplest thing i did was to create a jsp page which used woodstock components.. Here is how the sample jsp page looks.


 





 Great.. Now all thats left is including the necessary jars for woodstock components to work. The simplest way again for now is to take the jars present in the example app war that you find in the woodstock site.

I modified the build.xml found for the registration example app so that it included the necessary jar files. Here is what my build.xml included. I took out all the woodstock jars and put them inside a "woodstock" directory inside the examples directory of seam. (this would be helpful if i later experimented with other seam examples)




Next make sure your faces-config.xml has your facelet configuration parameter commented out. Also, make sure your web.xml is modified for woodstock components. Again, here is how mine looks like..  



 Now we are all set..  Compile your own modified registration application and make sure everything is built fine. Importantly make sure the woodstock and its dependent jars are included in the generated "ear" file.

Next just go ahead and deploy this application in glassfish. Here is how my registration application looks like.


Friday Oct 12, 2007

Seam is a framework from JBoss which helps you to develop enterprise level web 2.0 web applications. From the JBoss Seam site,

"JBoss Seam is a powerful new application framework for building next
generation Web 2.0 applications by unifying and integrating
technologies such as Asynchronous JavaScript and XML (AJAX), Java
Server Faces (JSF), Enterprise Java Beans (EJB3), Java Portlets and
Business Process Management (BPM)."

If you were to navigate to their home page, you would find them describing the most compelling reasons to use seam. Some of them being

- The first framework to use EJB 3.0 (really cool!)

- Easy way to do Ajax

- Backward compatibility with J2EE

 The most compelling feature i found in this framework was the combination of the JSF managed beans with EJB entity beans, so that you dont have to keep passing data back and forth between the entity beans and the managed beans. Also, you can use hibernate validators in the entity beans for validation instead of writing your own validators or specifying validtaors in the JSP page.

1) To get started, you would need the latest JBoss AS, and seam.(i used jboss 4.2.1 GA and seam 2.0.0.CR2)

You can download them from


http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942&release_id=523619

http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=163777

The seam download contains examples which you can use to see seam in action (there are a whole bunch of these examples with different frameworks in use).

2) Edit the build.properties file present in <SEAM-INSTALL> dirs o that the jboss.home references your AS location. For example here is what i put in for my jboss.home in my E:\seam





3) When building seam, i encountered a build failure which expected me to put a jar called jboss-seam-ui.jar and jboss-seam-ui-resources.jar inside a folder called "target" inside the "ui" folder.
i.e /ui/target. These jars can be found in the lib/ and lib/src directories

4) Make sure you have a working direct internet connection. The build process seams to download a lot of jars required for seam to build. If the build fails because it couldnt not download the jars, it instructs you to download them manually and install them. I made sure that i removed my proxy connection and had a direct internet connection so that the build process could go and fetch the jars from the seam repository.

5)  Now we are all set to build and run seam examples. Go inside the examples/ directory and issue an "ant" command.The build will complete successfully.

6) Go inside an example app (i used the registration example. it seemed the simplest of them all). and issue another "ant" command.

7) Start the JBoss app server and deploy the generated "ear" file into the server. (I copied the ".ear" file into <jboss-as-dir>/server/default/deploy dir).

8) Open your web browser and point it to http://localhost:8080/seam-registration.

This particular example uses JSF 1.2 with facelets 

You can go ahead modify these applications and see how things work.

For more instructions, there is a very good JBoss seam wiki at:

http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossSeam

and a good tutorial at:

http://labs.jboss.com/jbossseam/j2ee/part01.html

This blog copyright 2010 by venky