3

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.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
Sari Eiz
  • 77
  • 8
  • Are you using RichFaces 3.x or any other JSF 1.x targeted component library which attempts to **programmatically** set a `ViewHandler`? (i.e. not via `faces-config`). Basically, the answer would be to migrate that to a JSF 2.x compatible version, too. – BalusC Jan 22 '15 at 13:11
  • Yes, I'm using RichFaces3.1.4, Should I migrate that, too? If so, which version should I use? @BalusC – Sari Eiz Jan 22 '15 at 13:18

1 Answers1

3

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:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452