PrimeFaces’ betrayal

On March 24, 2013, in JSF, Open Source, PrimeFaces, Rants, by lucasterdev

PrimeFaces is now PrimeFace$, and isn’t open source anymore.

Their license page still reads:

PrimeFaces is open source, completely free to use and licensed under Apache License V2. Briefly you can use PrimeFaces in open source or commercial projects following the terms of the license.

Apache License

Version 2.0, January 2004

That’s not the case anymore, since private branches exist now that are only available to paying clients.

PrimeTek will now make sure that, from now on, only bug rigged, released once in a blue moon pre-alpha versions will be made available to the community, who will serve as a bunch of free beta testers.


Gracefully Handling ViewExpiredException

On March 17, 2013, in Java EE 6, JSF, JSF 2.0, by lucasterdev

ViewExpiredException usually occurs whena postback is triggered after the Session has expired. Here are a couple of ways to handle it:

Method #1: just use web.xml


Method #2: use JSF’s ExceptionHandler mechanism

Create an ExceptionHandlerFactory

package foo;

import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;

public class MyExceptionHandlerFactory extends ExceptionHandlerFactory {

	private ExceptionHandlerFactory parent;

	// This injection is handled by JSF
	public MyExceptionHandlerFactory(ExceptionHandlerFactory parent) {
		this.parent = parent;

	public ExceptionHandler getExceptionHandler() {
		return new MyExceptionHandler(parent.getExceptionHandler());


Implement your ExceptionHandler by extending ExceptionHandlerWrapper and overriding the handle() method

package foo;

import java.util.Iterator;
import java.util.logging.Logger;

import javax.faces.application.FacesMessage;
import javax.faces.application.ViewExpiredException;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerWrapper;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;

public class MyExceptionHandler extends ExceptionHandlerWrapper {

	private ExceptionHandler wrapped;

	Logger log;
	FacesContext fc;

	public MyExceptionHandler(ExceptionHandler exceptionHandler) {
		wrapped = exceptionHandler;
		log = Logger.getLogger(this.getClass().getName());
		fc = FacesContext.getCurrentInstance();

	public ExceptionHandler getWrapped() {
		return wrapped;

	public void handle() {

		Iterator<ExceptionQueuedEvent> i = super.getUnhandledExceptionQueuedEvents().iterator();

		while (i.hasNext()) {

			Throwable t =;

			if (t instanceof ViewExpiredException) {
				try {
					// Handle the exception, for example:
					log.severe("ViewExpiredException occurred!");
					fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "An exception occurred",
							"ViewExpiredException happened!"));
					fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "ViewExpiredException");
				finally {

			else if (t instanceof SomeOtherException) {
				// handle SomeOtherException


		// let the parent handle the rest


Register your ExceptionHandlerFactory in faces-config.xml

Tagged with: