• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

java.lang.RuntimeException: Cannot find FacesContext

Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying j_security_check in JSF Appplication. But i am getting following exception when i click on Login button of login.jsp

Here is the code :


if i am trying to access any other jsp form the application,the container forward the request to login.jsp ..but throwing following exception
if i access login.jsp then i can see the login page...but if i click on Login button..i am getting same exception

Here is exception :

does i am missing anything in configuration..???

Saloon Keeper
Posts: 24283
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The login process doesn't go through the normal dispatching channels for J2EE. The login page isn't (and CAN'T be) explicitly invoked by a URL. Instead, it's referenced directly by the webapp server as an internal resource.

As a result, there's no real guarantee that a login page that depends on a servlet-based framework such as JSF or Struts will be routed through their respective controller servlets. And since the FacesContext is created on a per-request basis by the FacesServlet, anything that doesn't go through FacesServlet will fail.

You have an even bigger problem, however. Like I said, the login page is invoked by the webapp server. That means that the webapp server is handling the login, not your application. You cannot invoke a custom login function using JSP, JSF, etc.. All the login/loginfail pages do is present a place to input userid and password. When you click the submit button, these 2 fields are then passed to the appserver's internal login function where it will validate the credentials and set up the J2EE security context (UserPrincipal and related objects). Or present the loginfail page if the userid/password weren't valid.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic