My Java EE web application is working fine with Glassfish 2.1. Now I want to migrate to Glassfish 3.1.1, but after a successful deployment of the war file it gives following
java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.
This is a typical error message when you use a JSF 1.2 targeted component library on a JSF 2.x environment. RichFaces 3.3.x is designed for JSF 1.2, but Glassfish 3.1 ships with JSF 2.1 instead of JSF 1.2 as in Glassfish 2.1. In JSF 2 there are quite a lot of changes in the area of view handling, because JSP has been deprecated and replaced by Facelets.
RichFaces has an excellent guide how to install and configure RichFaces 3.3.3 in a JSF 2 environment: RichFaces 3.3.3 and JSF 2.0. The key step to solve this particular exception is adding the following context parameter which disables the JSF 2 Facelets view handler:
javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER
true
But more steps needs to be done as well. Read the guide thoroughly.