IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered

1.3k views Asked by At

I've been migrating to from JSF 1.0 to JSF 2.2.

I'm getting the following error while trying to run my app:

JSP Error page Illegal attempt to set ViewHandler after a response has been rendered. | java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.

After reading some solutions to the problem I guess it's a matter of view-handler definition. What should be written in faces-config.xml instead of:

<view-handler>org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl</view-handler> ?

Obviously, if that's not the problem I'll be happy to hear that, too.

1

There are 1 answers

0
BalusC On BEST ANSWER

java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.

This exception will occur when an attempt is made to programmatically set a ViewHandler like below after the application has already served the first request/response:

context.getApplication().setViewHandler(new SomeViewHandler());

This is thus not related to any <view-handler> entry in faces-config.xml. Some other component library must be doing that. Among others RichFaces 3.x is known to do that (and is confirmed as per the comments on the question). You need to upgrade it to a JSF 2.x compatible version, which is at least RichFaces 4.x.

See also: