Review: JBoss AS 5 Development

I had the pleasure of being a technical reviewer on Packt’s JBoss AS 5 Development by Francesco Marchioni and I must say it was a fun ride. Being one of the few (if not the only) books released to date on JBoss AS 5, it is one very loaded one.

It provides detailed coverage of what’s new in the 5th iteration of the server, explaining into details its components. It then leads you down the path of setting up the server and tweaking it core i.e. thread pools, logging, JMX etc.

Using application examples, it then uncovers how to develop EJB Session beans, JPA or Hibernate entities and how they are used and configured, JSF, JBoss Messaging, JBoss Web Services and an indepth look at JMX. One very important topic covered in great detail is JBoss AS’s cluster configuration. The book ends with a discussion of JBoss Security.

The examples are developed with the help of the JBoss Tools Eclipse plugins, making for a tightly integrated experience with JBoss.

I’d recommend this book for both beginners and experts, and especially for the latter because of the depth of coverage of the more administrative sections of JBoss.

The book is available here.

Book Review: Packt’s JBoss Richfaces 3.3


Very good book on what is arguably the most popular JSF component library. Covers the less well used but very important ajax features of Richfaces, including the use of ajax regions, containers as well as the plug-n-skin features.


To all intents and purposes, this book is not for a beginner JSF developer, because it assumes familiarity with JSF 1.2. It starts off by delving into the history of the Richfaces component framework, which in eons past was just Ajax4jsf. It gives a short introduction (which is expounded later) on the ajax capabilities, the component set and skinability features of Richfaces for Rich Internet Application development.

It then sets off showing you step by step, how to create a simple JSF application that takes advantage of Richfaces as it’s JSF components library. It presents the seam-gen tool, a nifty tool for creating skeletons jsf projects based on the JBoss Seam project. Following the instructions on seam-gen enables you to create a quick prototype to start playing around with. This is then followed by instructions on how to manually create a project which is not Seam based, for fans of other frameworks which also integrate JSF, or for the pure JSF purists. This also includes configuring facelets support, and finally a look at how the IDEs provide support for development using the Richfaces component set.

The rest of the book, chapter by chapter, then focuses on using Richfaces components in building an interactive, intuitive and rich UI for your JSF application.

The following chapter delves into creating a JSF application using seam-gen (which I felt was repetitive, given that they’d actually created one in the preceding chapter), with additional parameters for defining the persistence model (entities) that were to be used in the application. It is worth noting from here forward almost all the examples now make use of the Seam framework’s programming model, something which could be a problem for those who are not Seam adherents. Also, with the stated assumption that this book is targeted at people with a basic knowledge of JSF, there didn’t seem to be the need to go over the basics of templating with Facelets and defining managed beans in a faces-config.xml file.

The next two chapters then introduce us to the intricate details of what the application is actually supposed to look like in terms of UI and functionality. The reader is taken through creating a database and generating entities from these, as well as creating a login page. I felt that these two chapters were the weakest chapters of the book, seeing as they dwelt more on entities, JPA and entities generation and Seam’s identity and login management than it did on the particular component framework in question – Richfaces. This may be explained by the fact that Richfaces enables the user to hook into Hibernate Validator for DRY enforcement on the domain model, the user could have been spared the parts on how to create the database, etc as well as Seam’s login management features.

Subsequently, the next chapter gives some very good insight on skinning, and implementing a means for the user to dynamically change skins. It explains the Richfaces’s use of XCSS, a powerful xml based means of describing CSS properties, as well as how to use some of the default Plug-n-Skin examples.

Chapter 6 then takes us deep into a real ajax experience, showing us the lesser explored but very important features provided by the rich:dataTable and rich:column components, as well as the appropriate use of the datascroller component for displaying tabular data. It also talks extensively about other data iteration components like the DataGrid and the DataList. Additionally, it goes into detail on the appropriate use of ajax placeholders, especially on using Richfaces outputPanel in achieving really ajax based changes to UI after changes are made to content, instead of just using JSF’s rendered attribute only.

The next chapter then deals with using the RichEditor as well as how to implement Drag’n’Drop support in your application. Finally an in-depth score is done on using the Richfaces FileUpload component.

Chapter 8 and 9 deal into more detail with skinning support in Richfaces, including how to create your own Plug’n’Skin skins, which can be quite easy if you follow the author’s guidance.

Chapter 10 dwells on advanced ajax capabilities such as Poll, Push as well as the partial update of data iteration components in the UI.

Of course, this book would not have been complete without discussing the Richfaces Component Development Kit (CDK). From creating a maven project using Richfaces’s CDK archetypes, to creating your own user defined components and registering them with the application, this chapter covers it all.

It ends with an appendix giving a short description of all the components currently provided by the Richfaces team.

What I like about this book.

This book contains a lot of information about how to really take advantage of the ajax capabilities provided by the Richfaces framework, and makes important mention of very valuable points to look out for when ajaxifying your application. I highly commend the indepth knowledge of Richfaces placeholders and the use of attributes like ajaxSingle and process, which gives your JSF application a true ajax feel.

What I don’t like about this book.

I’m an avowed fan of JBoss Seam, but I’d have preferred the book didn’t delve so deeply into Seam to make it’s point. As i mentioned before, some chapters dealt more with Seam than with Richfaces, and those may actually be quite annoying to someone who is developing with say Spring Web Flow.

Packt Publishing has attempted to pull off a book that provides an indepth look at the 3.3 version of the popular JSF component library, Richfaces. In a lot of ways, I believe they have managed to do just that, give or take a few points.

For more information about the book, visit:

A Home Made Eclipse CXF Plugin

I’d been looking around for web service stacks to use in a recent web service implementation I had. I read about both Apache Axis2 and CXF, but for various reasons I felt drawn to CXF.

Unfortunately, I realised that there was no web service runtime plugin for CXF as there is for Axis2. If you are just like me in this predicament, don’t give up just yet. I recently came across a way to get what I wanted, though not in as beautiful a solution as I’d have wanted. And the solution? Use, Eclipse’s External Tool Configurations. Here’s how you could also solve the problem.

  1. Create a new Java project named cxfclient.

  2. Copy the wsdl file to the src folder of the project.

  3. In the Eclipse menu, select Run → External Tools → External Tools Configuration.

  4. Click the “New launch Configuration” icon at the top of the left column. A “New_configuration” configuration is created.

  5. In the name field, provide the word “wsdl2java” as the name of the configuration.

  6. In the “Main” tab, provided the following values in the respective fields

    1. Location – Click “Browse File System” and navigate to the location where your cxf download is extracted to.

    2. Working directory – Click “Browse Workspace” which should show the list of projects in your Eclipse workspace. Select the “src” folder of your project, since the generated classes will be put there, and your wsdl file is also located there.

    3. Arguments – The only argument that we will provide in this process is the name of the WSDL file, in this case Calculator.wsdl. However, this is where any extra parameters can be passed to wsdl2java to tweak its behaviour. For example, to generate a consumer of the Calculator service, specify “-client” before the name of the wsdl file.

  7. Click the “Refresh” tab and check the “Refresh resources upon completion”.

  8. Click “Apply” to make all these changes permanent.

  9. Click “Run” to see your generated implementations of the Calculator service. Your configuration should look like this.

You can apply this trick to add any tool that is not yet integrated into Eclipse but has command line tools to work with. Enjoy tweaking.

JSF Applications – JBoss Seam or Spring Web Flow?

I’ve had opportunity to use JBoss Seam from its 1.0 days, and also Spring Web Flow. I must admit that both frameworks really do hold their own in providing you with a full stack for rapid application development. This post does not attempt to look at these frameworks as a whole, but to focus on how easy it is to develop JSF
applications in them.

JSF is a Java standard for web application development. Therefore to judge any framework that depends on or claims to accelerate JSF, we will focus on how it scales over the gaping holes that are not handled by the standard, not just how they stick to it. Below are my observations. Note that the following points are not given in
any order of importance.

JSF’s UISelectItems Support

From somewhere in it’s 1.x version, Seam has provided the ability to use just a normal java.util.List of your own domain objects e.g. List<Student> directly to populate JSF’s UISelectItem controls like list boxes, drop down lists etc using their <s:selectItems/> component and it’s attached <s:convertEntity/> tag. Additionally, enums are easily handled in like manner using <s:convertEnum/> and <s:enumItem/>. This gets rid of the need to wrap domain objects in JSF SelectItem instances.

This is sorely lacking in Spring Faces, Spring’s JSF support for Web Flow, something I have even voted for in their JIRA instance.

Conversation Propagation in a Different Browser Tab

Seam provides the ability to invoke actions that start a new conversation or to move within states in a conversation using their provided <s:button/> or <s:link/> button and link respectively. Though Spring Faces has a Dojo backed
<sf:commandButton/> and <sf:commandLink/>, these are not yet capable of achieving this.

Integration with Hibernate Validator

Following the DRY principle, it can be very useful if JSF can also hook into the validation defined on your domain model using the defacto validation standard, Hibernate Validator. As you may already know, JSR-303 Bean Validation is targeted at standardizing the definition and enforcement of validation rules on your domain model,
with Hibernate Validator as the reference implementation. Seam provides the ability to enforce these validations in your JSF UI using the <s:validateAll/> tag.

Although requests have been made for this support, I’m yet to see it in Spring Faces.

Popup Screens

Sometimes it is cool to show modal panels for quick response from the user when interacting with the UI instead of a full page refresh. Spring Faces natively provides a Dojo based modal panel accessed just
by setting “popup” to true on any view state.

It is important to note however that though not natively supported in Seam, both it’s default JSF component library, RichFaces and the supported alternatives, ICEFaces and Trinidad, all provide this functionality

Display of byte[] images

JSF doesn’t provide any native control for the display of images from a byte array (byte[]) most probably retrieved from a database. The standard <h:graphicImage/> only deals with files accessible through a url. Seam however, provides support for display of images in a byte arrays using it’s <s:graphicImage/>.

There is no such support in Spring Faces, though RichFaces’s <a4j:mediaOutput/> could be used in displaying such content, however I have had problems using it with Spring Faces. ICEFaces also could be used to achieve this.

File Upload

Another vital component missing from the standard JSF toolkit is a file upload component of which Seam natively provides an <s:fileUpload/> component for achieving just that.

Unless you us a third party library like RichFaces or ICEFaces, I haven’t yet seen clear support for such a functionality in SpringFaces.

Rendering Components Based on Access Rights

Sometimes you want to hide a certain area of your UI from the user based on their roles/rights within the application. This is normally achieved in JSF using the “rendered” attribute on any tag or component. Seam provides a native way to easily hide or show components or sections using the s:hasRole EL function. An example of
this is below

<h:outputText value=”Hello”

This same support is extended to its “s:hasPermission” function, allowing you to render components on the UI based on not only roles, but fine grained permissions even backed by the Drools engine. And these functions are accessible whether on the UI, in your navigation rules (when you use pages.xml or pdl) and even in your code on annotations.

Spring Faces has no native support for this on facelets (I think it’s only available on jsps). However, an open-source project, Acegi-JSF, has a UI component tag <acegijsf:authorize/> and other additional ones which allow you to render based on access rights. This is limited, in that it cannot be applied to the rendered” attributes of JSF components since it is by itself a component/tag, not an EL function like Seam’s approach. You have to be quite inventive (and verbose) to come up with your own solutions to this problem.

Extended EL Capabilities

JSF 1.2 is limited in it’s EL support, and as a result you cannot invoke an action with parameters on a facelet. The following is not allowed, though I’ve seen proposals to fix it natively in

<h:commandButton action=”#{shop.buyProduct(product)}”/>

Seam uses it’s own implementation of the EL-API called the JBoss EL, and this allows the invocation of such actions in a facelet and in your navigation rules.

Though Spring Faces also uses JBoss EL, for some reason I haven’t been able to do anything like the above in my facelet, though it is possible in flow (it is a heavily used feature Spring Web Flow).

Automatic Detection of Converters & Validators Through Annotations

One may be forced to write some converters or validators needed to meet specific business logic needs. JSF requires you to specify these classes in it’s faces-config.xml file before being used.

Seam provides annotations for auto-discovering JSF converters and validators, meaning there is no need for the “xml hell” when creating these components.

Spring Faces doesn’t yet have this support.

TimeZones & Themes

The JSF specification assumes that all dates and times are UTC. To override this behaviour, a timezone must specified using an <f:convertDateTime/> on each date being displayed. The inconvenience of this cannot be overstated as I’ve had to deal with this. Using a Seam component on which the Time Zone may be specified in your application, Seam overrides this behaviour in your JSF application, a feature I’m yet to see in SpringFaces.

Also, most of today’s webapps come with the ability to change themes on the fly, but JSF has no native support for  themes. This support however is provided by Seam in a very easy to configure way, and is yet to make it to Spring Faces.


JSF by nature is designed with tools in mind, as result, tool support is an important part of adoption of JSF and every JSF framework’s tool support must be brought under the scope.

JBoss provides JBoss Tools, a superb set of tools for rapid application design. It’s Richfaces VPE provides wysiwyg, drag n’ drop design of facelets with a palette of HTML,JSF, Facelets and Richfaces components. It also supports resolution of your seam components inside facelet using Seam component names as well as wysiwyg declaration of
nagivation rules in both the standard JSF faces-config.xml or and Seam’s pages.xml. Even resolution of component names in code is also available. See the JBoss Tools Developer Guide for more on this toolset.

Spring provides it’s own Spring IDE set of tools which also allow the resolution of Spring beans within your flow definitions. Unfortunately, there isn’t any wysiwig support and Spring beans cannot be resolved by the Richfaces VPE.

Other Non-JSF Stuff For UI Developers

Conversation Switcher

With both frameworks promising the ability to have long running conversations, it then becomes useful to be able to start different conversations concerning different things, and have knowledge on the UI of which conversations have been started and the state in which the user is in each conversation.

This is natively supported in Seam but not in Web Flow.

Debug page

It helps to know the state and content of the beans in your scopes, especially when you want to know why certain things are not showing up on your facelet, without having to set break points in your IDE and start a whole debugging process.

Seam gives you the ability to at any time in any conversation, see the contents of your components in their appropriate scopes. This I sorely missed in Web Flow.


There are a host of other things that we could also compare, but from these ones it is not difficult to see why people who develop using the JSF framework see Seam as a saviour. We could choose
to chastise JSF itself for its shortcomings and use other frameworks but when someone comes along and makes standards like JSF more attractive as their first priority, I think they deserve the support and commendation. And that is what I believe is the problem with Spring Web Flow and it’s
Spring Faces project.

Spring has it’s own MVC framework, SpringMVC which predates Web Flow. Web Flow can be developed either using SpringMVC or JSF aka Spring Faces. A lot of the limitations of Spring Faces noted here are already handled natively by SpringMVC. Obviously, Spring Faces has not had the kind of attention that the first class citizen, SpringMVC
has in the world of Spring. In fact, one wonders if the sudden entrance of Spring Faces is not just a knee jerk reaction to Seam winning the JSF folks over.

I believe that if you had to develop a JSF application and did not have any investments in Spring already, it will make more sense to go for Seam as your preferred framework. Coupled with it’s advanced tooling, there isn’t as yet a better choice. Trust me, you won’t regret it.

Seam also has support for other web frameworks like GWT and Wicket. Though Seam’s support of Wicket is very young, it will be interesting to see what
the community’s acceptance of it is.

Technorati Tags: , , , ,

Using Eclipse Dali with Hibernate as Persistence Provider

Eclipse Ganymede comes with in built support for the EclipseLink JPA implementation. However, we’ll want to explore how to use Hibernate’s JPA implementation with Eclipse Dali for JPA operations

To begin with, please make sure you have the following

  1. Eclipse Ganymede for JavaEE

  2. Hibernate EntityManager

  3. Hibernate Tools

  4. MySQL connector (or a jdbc connector of your choice if you are not using MySQL)

You will need to install Hibernate Tools as an Eclipse plugin. Next, you’ll have to add MySQL to your list of driver definitions. This you do by going to the “Window” → “Preferences”. On the left tree, navigate to “Data Management” → “Connectivity” → “Driver Definitions”. Click on the “Add” button. You now have a “New Driver Definition” window with three tabs – Name/Type, Jar List and Properties.

In the Name/Type tab, select MySQL. A list of choices now appears of “MySQL JDBC Driver”. Select System Version 5.0, click on the “Jar List” tab and delete the default MySQL driver file specified there. Click on “Add Jar/Zip” and add your MySQL connector. Please ensure that there are no spaces in the path to your MySQL connector, or you may have trouble later on. Click “Ok” to finish the driver definition.

Next is to add the Hibernate EntityManager libraries as your JPA implementation. First, extract the Hibernate EntityManager zip that you downloaded into a location without spaces in the path. Still in the “Preferences” window, click on “JPA” on the left tree. In the “Default JPA Implementation Library”, click the “Configure user libraries” link. Click on the “New” button and give this a good name e.g. HibernateJPA. Click on “Add JARs” and add the “hibernate-entitymanager.jar” that is available in your extracted Hibernate EntityManager folder. Next, add all the jars in the lib folder of the extracted folder. These should be

  • slf4j-api.jar
  • dom4j.jar
  • ejb3-persistence.jar
  • hibernate-annotations.jar
  • hibernate-commons-annotations.jar
  • hibernate-core.jar
  • javassist.jar
  • jta.jar

Click on “Ok” to complete adding the JPA implementation.

Now, create a Java Project called “jpaproject”. In the project explorer view, right-click the project and select “JPA Tools” → “Convert To JPA Project”. Click on “Next” on the “Project Facets” screen that shows up. On the “Configure JPA Settings” window, select “Hibernate” as your platform. You will now add your connection to the database by clicking on “Add connection” link. In the “Connection Profile” window, type MySQL in the filter. Select MySQL and enter the name “jpaprojectDB” in the “Name” field. Click “Next”, and specify your database connection details. Click “Test connection” to be sure, and then “Finish” when completed.

You should now have something like below

Remember to uncheck the “Create orm.xml” option. Its useless overhead we don’t need now. You now have a project that supports JPA, with a META-INF/persistence.xml file generated in your src folder. Funny enough, after all this information provided, Dali still refuses to populate your persistence.xml file with these details. You will have to do them yourself (talk about DRY).

Double-click on your persistence.xml. On the “General” tab, specify “org.hibernate.ejb.HibernatePersistence” as your Persistence Provider. In the “Connection” tab, choose “Resource Local” from the Transaction Type drop down list. Under “Hibernate” tab, select “MySQL” as Database dialect, “com.mysql.jdbc.Driver” as Driver class, “jdbc:mysql://localhost:3306/jaccra” as your connection URL, and then provided the username and password fields for the database connection. Click on “Source” and you should something close to the ff.


<persistence version=“1.0” xmlns=;

<persistence-unit name=“jpaproject” transaction-type=“RESOURCE_LOCAL”>



<property name=“hibernate.dialect” value=“org.hibernate.dialect.MySQLDialect”/>

<property name=“hibernate.connection.driver_class” value=“com.mysql.jdbc.Driver”/>

<property name=“hibernate.connection.url” value=“jdbc:mysql://localhost:3306/jaccra”/>

<property name=“hibernate.connection.username” value=“edem”/>

<property name=“hibernate.connection.password” value=“edem”/>




Now you are all set up for your JPA machinations. One last and very important thing to do is to add the MySQL connect jar to your build path. Now when you right-click on your project in the project explorer, you should see an option “JPA Tools”, under which there are a couple of other options. Explore them and see what you get.