title: JSF NullPointerException at SeamViewHandler.calculateLocale
body: <p>I have been trying to read a database in my JSF webapp. I am using the code given from BalusC Code blog:</p>
  
  <ul>
  <li><a href="http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html" rel="nofollow">http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html</a></li>
  <li><a href="http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jsf.html" rel="nofollow">http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jsf.html</a></li>
  </ul>
  
  <p>However when I set up everything and I launch it on Tomcat 6 I got this error (full stractrace): </p>
  
  <pre><code>SEVERE: uncaught exception
  java.lang.NullPointerException
      at org.jboss.seam.Component.getInstance(Component.java:1859)
      at org.jboss.seam.Component.getInstance(Component.java:1852)
      at org.jboss.seam.Component.getInstance(Component.java:1829)
      at org.jboss.seam.web.Session.getInstance(Session.java:122)
      at org.jboss.seam.contexts.FacesLifecycle.beginRequest(FacesLifecycle.java:54)
      at org.jboss.seam.jsf.SeamPhaseListener.beforeRestoreView(SeamPhaseListener.java:366)
      at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:137)
      at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
      at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  2011-01-28 15:38:46 org.jboss.seam.jsf.SeamPhaseListener beforePhase
  SEVERE: swallowing exception
  java.lang.NullPointerException
      at org.jboss.seam.Component.getInstance(Component.java:1859)
      at org.jboss.seam.Component.getInstance(Component.java:1852)
      at org.jboss.seam.Component.getInstance(Component.java:1829)
      at org.jboss.seam.web.Session.getInstance(Session.java:122)
      at org.jboss.seam.contexts.FacesLifecycle.beginRequest(FacesLifecycle.java:54)
      at org.jboss.seam.jsf.SeamPhaseListener.beforeRestoreView(SeamPhaseListener.java:366)
      at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:137)
      at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
      at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  2011-01-28 15:38:46 com.sun.faces.lifecycle.Phase doPhase
  SEVERE: JSF1054: (Phase ID: RESTORE_VIEW 1, View ID: ) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@ce2c57]
  2011-01-28 15:38:46 org.jboss.seam.jsf.SeamPhaseListener afterPhase
  SEVERE: uncaught exception
  java.lang.NullPointerException
      at org.jboss.seam.jsf.SeamPhaseListener.raiseEventsAfterPhase(SeamPhaseListener.java:421)
      at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:175)
      at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  2011-01-28 15:38:46 org.jboss.seam.jsf.SeamPhaseListener afterPhase
  SEVERE: swallowing exception
  java.lang.NullPointerException
      at org.jboss.seam.jsf.SeamPhaseListener.raiseEventsAfterPhase(SeamPhaseListener.java:421)
      at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:175)
      at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  2011-01-28 15:38:46 org.ajax4jsf.webapp.BaseXMLFilter doXmlFilter
  SEVERE: Exception in the filter chain
  javax.servlet.ServletException
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.NullPointerException
      at org.jboss.seam.jsf.SeamViewHandler.calculateLocale(SeamViewHandler.java:55)
      at org.ajax4jsf.application.ViewHandlerWrapper.calculateLocale(ViewHandlerWrapper.java:65)
      at com.sun.faces.application.ViewHandlerImpl.createView(ViewHandlerImpl.java:372)
      at org.jboss.seam.jsf.SeamViewHandler.createView(SeamViewHandler.java:68)
      at org.ajax4jsf.application.ViewHandlerWrapper.createView(ViewHandlerWrapper.java:79)
      at org.ajax4jsf.application.AjaxViewHandler.createView(AjaxViewHandler.java:93)
      at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:204)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      ... 18 more
  </code></pre>