Upgrading RichFaces 4.0.0.A2 to 4.0.0.M1

Last week RichFaces 4.0.0.M1 was released. If you are using Maven, then its relatively easy to upgrade from Alpha2 to M1. If you’ve not started using RichFaces 4 yet in your applications, then full details of how to install RichFaces in a Maven application are provided on the JBoss Wiki.

To upgrade from A2 to M1, should just be a matter of upgrading the version number in your pom.xml file, cleaning and building your project. The main thing to note however is that the version number is “4.0.0.20100715-M1″ rather than simply “4.0.0.M1″ as would have been expected. An upgraded version property would therefore read as:

<properties>
  <org.richfaces.ui.version>4.0.0.20100715-M1</org.richfaces.ui.version>
</properties>

After upgrading the version of RichFaces however, I found a problem in that dependencies on org.w3c.css.sac and net.sourceforge.cssparser.cssparser are not properly discovered. Without these additional Jars, the following exception is thrown at runtime:

java.lang.NoClassDefFoundError: org/w3c/css/sac/ErrorHandler
 org.richfaces.resource.ResourceHandlerImpl.createResource
  (ResourceHandlerImpl.java:460)
 org.richfaces.resource.ResourceHandlerImpl.createResource
  (ResourceHandlerImpl.java:483)
 com.sun.faces.renderkit.html_basic.StylesheetRenderer.encodeEnd
  (StylesheetRenderer.java:91)
 javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
 com.sun.faces.renderkit.html_basic.HeadRenderer.encodeEnd(HeadRenderer.java:93)
 javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
 javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
 com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView
   (FaceletViewHandlingStrategy.java:380)
 com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
 javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
 org.jboss.weld.servlet.ConversationPropagationFilter.doFilter
  (ConversationPropagationFilter.java:68)

This can be fixed easily however, by adding the following dependencies into your POM file.

<dependency>
  <groupId>org.w3c.css</groupId>
  <artifactId>sac</artifactId>
  <version>1.3</version>
</dependency>
<dependency>
  <groupId>net.sourceforge.cssparser</groupId>
  <artifactId>cssparser</artifactId>
  <version>0.9.5</version>
</dependency>