Friday, November 30, 2007

JSF-Spring Integration

If you follow this link you can easily your existing web application which uses JSF with spring.
But
when you run tomcat 6.0 you can take this output in console.

java.lang.IllegalStateException: No thread-bound request found: Are you
> referring to request attributes outside of an actual web request?
> If you are actually operating within a web request and still receive this
> message,your code is probably running outside of
> DispatcherServlet/DispatcherPortlet: In this case, use
> RequestContextListener or RequestContextFilter to expose the current
> request.

It is because of this:
http://www.jdocs.com/page/AjaxSourceCode?oid=62833

at line 102

You can fix it with modify your web.xml. Add this listener to your web.xml

org.springframework.web.context.request.RequestContextListener


As a result, your working web.xml should contain listeners below.
//listeners
com.sun.faces.config.ConfigureListener

org.springframework.web.context.ContextLoaderListener

org.springframework.web.context.request.RequestContextListener

de.mindmatters.faces.spring.context.ContextLoaderListener

//end of listeners