Hi,

I am having an application with implements JSF with EJB3.0 and Shale as the controller. I am using Jboss 4.2.3 to implement JAAS feature. I have the required configuration like login-config.xml, jboss-web.xml and web.xml. I am using org.jboss.security.auth.spi.DatabaseServerLoginMod ule for authentication.

WhenI try to login using login.jsf, the server log shows that the correct values are passed for user and password (testuser, testuser123) but still I am unable to login.

Also when I try to print the values using the helper-methods getRemoteUser and getUserPrincipal, I see null in my log. Please help as I am unable to login as I kepe getting authentication failure even though the values are present in the required tables and views used in login-config.xml.

public String getUserPrincipal()
{
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
return externalContext.getUserPrincipal() != null ? externalContext.getUserPrincipal().toString() : "null";
}

public String getRemoteUser()
{
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
String remoteUser = externalContext.getRemoteUser();
return remoteUser;
}

Server log:

2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Postback: Restored view for /login.jsf
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Exiting RestoreViewPhase
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase RESTORE_VIEW 1
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.timing] [TIMING] - [0ms] : Execution time for phase (including any PhaseListeners) -> RESTORE_VIEW 1
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase APPLY_REQUEST_VALUES 2
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Entering ApplyRequestValuesPhase
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.RendererBase] Start decoding of component _viewRoot with class org.ajax4jsf.component.AjaxViewRoot
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.AjaxContainerRenderer] Decode ajax request status for _viewRoot
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.component.AjaxRegionBrige] Submitted AJAX request - Queue Event to AjaxListeners
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.RendererBase] Start decoding of component j_id6 with class org.richfaces.component.html.HtmlToolTip
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.RendererBase] Start decoding of component j_id7 with class org.richfaces.component.html.HtmlToolTip
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] UIForm with client ID login, submitted
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] No decoding necessary since the component username is not an instance or a sub class of UIInput
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] Set submitted value testuser on component
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] new value after decoding testuser
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] No decoding necessary since the component j_id12 is not an instance or a sub class of UIInput
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.RendererBase] Start decoding of component login:j_id11 with class org.richfaces.component.html.HtmlRichMessage
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] No decoding necessary since the component password is not an instance or a sub class of UIInput
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] Set submitted value testuser123 on component
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] new value after decoding testuser123
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] No decoding necessary since the component j_id17 is not an instance or a sub class of UIInput
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.RendererBase] Start decoding of component login:j_id16 with class org.richfaces.component.html.HtmlRichMessage
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.RendererBase] Start decoding of component login:submit with class org.ajax4jsf.component.html.HtmlAjaxCommandLink
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.renderkit.AjaxCommandRendererBase] Decode submit of the Ajax component login:submit
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Exiting ApplyRequestValuesPhase
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase APPLY_REQUEST_VALUES 2
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.timing] [TIMING] - [0ms] : Execution time for phase (including any PhaseListeners) -> APPLY_REQUEST_VALUES 2
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase PROCESS_VALIDATIONS 3
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Entering ProcessValidationsPhase
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] No conversion necessary for value testuser of component usernameField
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.renderk it] No conversion necessary for value testuser123 of component passwordField
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Exiting ProcessValidationsPhase
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase PROCESS_VALIDATIONS 3
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.timing] [TIMING] - [0ms] : Execution time for phase (including any PhaseListeners) -> PROCESS_VALIDATIONS 3
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase UPDATE_MODEL_VALUES 4
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Entering UpdateModelValuesPhase
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process after phase UPDATE_MODEL_VALUES 4
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.timing] [TIMING] - [0ms] : Execution time for phase (including any PhaseListeners) -> UPDATE_MODEL_VALUES 4
2009-03-18 19:46:19,609 DEBUG [org.ajax4jsf.event.AjaxPhaseListener] Process before phase INVOKE_APPLICATION 5
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.lifecyc le] Entering InvokeApplicationsPhase
2009-03-18 19:46:19,609 DEBUG [javax.enterprise.resource.webcontainer.jsf.applica tion] processAction(submit)
2009-03-18 19:46:19,609 INFO [STDOUT] userPrincipal: null
2009-03-18 19:46:19,609 INFO [STDOUT] remoteUser: null
2009-03-18 19:46:19,609 DEBUG [org.jboss.ejb3.security.Ejb3AuthenticationIntercep tor] Authentication failure
javax.security.auth.login.LoginException: java.lang.NullPointerException
at org.jboss.security.Util.createPasswordHash(Util.ja va:409)
at org.jboss.security.auth.spi.UsernamePasswordLoginM odule.createPasswordHash(UsernamePasswordLoginModu le.java:415)
at org.jboss.security.auth.spi.UsernamePasswordLoginM odule.login(UsernamePasswordLoginModule.java:204)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.security.auth.login.LoginContext.invoke(Unkn own Source)
at javax.security.auth.login.LoginContext.access$000( Unknown Source)
at javax.security.auth.login.LoginContext$4.run(Unkno wn Source)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv( Unknown Source)
at javax.security.auth.login.LoginContext.login(Unkno wn Source)
at org.jboss.security.plugins.JaasSecurityManager.def aultLogin(JaasSecurityManager.java:603)
at org.jboss.security.plugins.JaasSecurityManager.aut henticate(JaasSecurityManager.java:537)
at org.jboss.security.plugins.JaasSecurityManager.isV alid(JaasSecurityManager.java:344)
at org.jboss.aspects.security.AuthenticationIntercept or.authenticate(AuthenticationInterceptor.java:123 )
at org.jboss.aspects.security.AuthenticationIntercept or.invoke(AuthenticationInterceptor.java:66)
at org.jboss.ejb3.security.Ejb3AuthenticationIntercep tor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(EN CPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousIntercepto r.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localI nvoke(StatelessContainer.java:240)
at org.jboss.ejb3.stateless.StatelessContainer.localI nvoke(StatelessContainer.java:210)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invok e(StatelessLocalProxy.java:84)
at $Proxy120.doLogin(Unknown Source)
at com.sortmybooksonline.web.controller.LoginControll er.doLogin(LoginController.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java :131)
at org.apache.el.MethodExpressionImpl.invoke(MethodEx pressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(Tag MethodExpression.java:68)
at javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:88)
at com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:102)
at org.apache.shale.view.faces.ViewActionListener.pro cessAction(ViewActionListener.java:74)
at javax.faces.component.UICommand.broadcast(UIComman d.java:387)
at org.ajax4jsf.component.AjaxActionComponent.broadca st(AjaxActionComponent.java:55)
at org.ajax4jsf.component.AjaxViewRoot.processEvents( AjaxViewRoot.java:321)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvent s(AjaxViewRoot.java:296)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(A jaxViewRoot.java:253)
at org.ajax4jsf.component.AjaxViewRoot.processApplica tion(AjaxViewRoot.java:466)
at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 00)
at com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServl et.java:265)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter. doFilter(ExtensionsFilter.java:301)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(Base XMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseF ilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHa ndleRequest(BaseFilter.java:390)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter .java:517)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.shale.application.faces.ShaleApplicatio nFilter.doFilter(ShaleApplicationFilter.java:267)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:432)
at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionV alve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)

at javax.security.auth.login.LoginContext.invoke(Unkn own Source)
at javax.security.auth.login.LoginContext.access$000( Unknown Source)
at javax.security.auth.login.LoginContext$4.run(Unkno wn Source)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv( Unknown Source)
at javax.security.auth.login.LoginContext.login(Unkno wn Source)
at org.jboss.security.plugins.JaasSecurityManager.def aultLogin(JaasSecurityManager.java:603)
at org.jboss.security.plugins.JaasSecurityManager.aut henticate(JaasSecurityManager.java:537)
at org.jboss.security.plugins.JaasSecurityManager.isV alid(JaasSecurityManager.java:344)
at org.jboss.aspects.security.AuthenticationIntercept or.authenticate(AuthenticationInterceptor.java:123 )
at org.jboss.aspects.security.AuthenticationIntercept or.invoke(AuthenticationInterceptor.java:66)
at org.jboss.ejb3.security.Ejb3AuthenticationIntercep tor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(EN CPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousIntercepto r.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNex t(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localI nvoke(StatelessContainer.java:240)
at org.jboss.ejb3.stateless.StatelessContainer.localI nvoke(StatelessContainer.java:210)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invok e(StatelessLocalProxy.java:84)
at $Proxy120.doLogin(Unknown Source)
at com.sortmybooksonline.web.controller.LoginControll er.doLogin(LoginController.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java :131)
at org.apache.el.MethodExpressionImpl.invoke(MethodEx pressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(Tag MethodExpression.java:68)
at javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:88)
at com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:102)
at org.apache.shale.view.faces.ViewActionListener.pro cessAction(ViewActionListener.java:74)
at javax.faces.component.UICommand.broadcast(UIComman d.java:387)
at org.ajax4jsf.component.AjaxActionComponent.broadca st(AjaxActionComponent.java:55)
at org.ajax4jsf.component.AjaxViewRoot.processEvents( AjaxViewRoot.java:321)
at org.ajax4jsf.component.AjaxViewRoot.broadcastEvent s(AjaxViewRoot.java:296)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(A jaxViewRoot.java:253)
at org.ajax4jsf.component.AjaxViewRoot.processApplica tion(AjaxViewRoot.java:466)
at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 00)
at com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServl et.java:265)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter. doFilter(ExtensionsFilter.java:301)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(Base XMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseF ilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHa ndleRequest(BaseFilter.java:390)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter .java:517)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.shale.application.faces.ShaleApplicatio nFilter.doFilter(ShaleApplicationFilter.java:267)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:432)
at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionV alve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:446)
at java.lang.Thread.run(Unknown Source)