04 May 2009

JSF ViewExpiredException fix

After spending some time wrestling with this beast, I might have found a solution. Here's the scenario:
  1. Launch a very simple JSF app consisting of two pages, as described by the Select example from Chapter 4 of the Core JavaServer Faces book by D. Geary and C. Horstmann (no database calls).
  2. Allow the session to time out.
  3. Use your browser's back button to return to the index.faces page.
  4. Re-submit the form.
  5. Watch the app blow up with this exception:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: viewId:/index.faces - View /index.faces could not be restored.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

javax.faces.application.ViewExpiredException: viewId:/index.faces - View /index.faces could not be restored.
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:186)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

After a lot of research on the web, the following context parameter in the web.xml file resolves it:
 <context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

To see it in action, set your session timeout to 1 minute in web.xml:
   <session-config>  
<session-timeout>1</session-timeout>
</session-config>

However, be careful using this setting: You will cause the entire UI component tree to be serialized and passed to the client. This can increase download lag time, especially on more complex layouts. Also, there are times when sessions must expire (authenticated sessions), so you'd want to stick with the server for your state saving method in most cases.

30 April 2009

Run Mono in Visual Studio

Visual Studio uses the Microsoft .NET Framework and doesn't seem to provide an easy way to use Mono. Well, here's an article to lead the way to easier Mono and Visual Studio integration. Part 2 of the article addresses some common errors. Thanks, Christopher Cyvas, for the great articles and templates!

23 April 2009

See the auto-starting apps in Windows

Autoruns for Windows is a free tool from Microsoft to let you see what processes start up when you boot the OS. You can also disable individual items, though you should proceed with caution.

21 April 2009

Adobe Strobe

Adobe will be highlighting a new technology effort called Strobe at the National Association of Broadcasters. Read more about it here: http://www.eweek.com/c/a/Application-Development/Adobe-Delivers-New-Content-Creation-Delivery-and-Playback-Technologies-at-NAB-2009-267323/

Java's future unclear

Infoworld talks about Java's future under Oracle ownership: http://www.infoworld.com/d/open-source/java-we-know-it-doomed-298?source=NLC-DAILY

Update: Why Oracle's acquisition of Sun is good news for Microsoft.

17 April 2009

Free Autodesk software for faculty/staff

You can get the powerful Autodesk software for free if you're a student or faculty: http://students8.autodesk.com/?nd=register

.NET SDK for Google API

Google has developed its .NET SDK for its various technologies (YouTube, Documents, Picasa): http://code.google.com/p/google-gdata/downloads/list