title: Cannot login using Wildfly security domain
body: <p>I am migrating from glassfish 4 to wildfly 8.1</p>
  
  <p>Problem is in login using security domain of Wilfly. I cannot find solution for hours. </p>
  
  <p>here is my standalone-full.xml security domain configuration:</p>
  
  <pre><code>&lt;security-domain name="aisRealm" cache-type="default"&gt;
                      &lt;authentication&gt;
                          &lt;login-module code="Database" flag="required"&gt;
                              &lt;module-option name="dsJndiName" value="java:/jdbc/ais"/&gt;
                              &lt;module-option name="principalsQuery" value="select password from users where email='subsoil_user'"/&gt;
                              &lt;module-option name="rolesQuery" value="select ug.group_name, 'Roles' from user_in_group uig, users u, user_group ug where uig.user_id = u.id and uig.user_group_id = ug.id and u.email = 'subsoil_user'"/&gt;
                              &lt;module-option name="hashAlgorithm" value="SHA-256"/&gt;
                              &lt;module-option name="hashEncoding" value="BASE64"/&gt;
                              &lt;module-option name="unauthenticatedIdentity" value="guest"/&gt;
                          &lt;/login-module&gt;
                          &lt;login-module code="RoleMapping" flag="required"&gt;
                              &lt;module-option name="rolesProperties" value="file:${jboss.server.config.dir}/ais.properties"/&gt;
                              &lt;module-option name="replaceRole" value="false"/&gt;
                          &lt;/login-module&gt;
                      &lt;/authentication&gt;
                  &lt;/security-domain&gt;
  </code></pre>
  
  <p>alse here I have made default security domain </p>
  
  <pre><code>&lt;default-security-domain value="aisRealm"/&gt;
  </code></pre>
  
  <p>here is my configurations in web.xml:</p>
  
  <pre><code>&lt;login-config&gt;
          &lt;auth-method&gt;FORM&lt;/auth-method&gt;
          &lt;realm-name&gt;aisRealm&lt;/realm-name&gt;
          &lt;form-login-config&gt;
              &lt;form-login-page&gt;/login.xhtml&lt;/form-login-page&gt;
              &lt;form-error-page&gt;/login_error.xhtml&lt;/form-error-page&gt;
          &lt;/form-login-config&gt;
      &lt;/login-config&gt;
  </code></pre>
  
  <p>here is configurations in ais.properties:</p>
  
  <pre><code>ADMIN=ADMIN
  SUBSOIL_USER=SUBSOIL_USER
  SUPPLIER=SUPPLIER
  </code></pre>
  
  <p>and jboss-web.xml configuration:</p>
  
  <pre><code>&lt;security-domain&gt;aisRealm&lt;/security-domain&gt;
  </code></pre>
  
  <p>login.xhtml:</p>
  
  <pre><code>&lt;h:form&gt;  
                  &lt;h:panelGrid columns="3" columnClasses="login, pass, login_btn"&gt;                    
                      &lt;h:inputText id="loginName" value="#{userBean.loginName}" /&gt;                      
                      &lt;h:inputSecret id="password" value="#{userBean.password}" /&gt;  
                      &lt;p:commandButton id="loginButton" value="#{dictionary['login']}" action="#{userBean.login}" ajax="false"/&gt;                                                              
                      &lt;ui:remove&gt;
                          &lt;p:commandButton id="loginButton" value="#{dictionary['login']}" action="#{userBean.login}" process="@this"/&gt;  
                      &lt;/ui:remove&gt;                    
                  &lt;/h:panelGrid&gt;  
              &lt;/h:form&gt;   
  </code></pre>
  
  <p>UserBean Login function:</p>
  
  <pre><code>public void login() {
          FacesContext facesContext = FacesContext.getCurrentInstance();
          HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
  
          try {
              request.login(loginName, password);
  
          } catch (ServletException e) {
              Logger.getLogger(UserBean.class.getName()).log(Level.SEVERE, null, e);
              try {
                  facesContext.getExternalContext().redirect(facesContext.getExternalContext().getRequestContextPath() + "/error?statusCode=login_failed");
                  return;
              } catch (IOException ex) {
                  Logger.getLogger(UserBean.class.getName()).log(Level.SEVERE, null, ex);
              }
          }   } 
  </code></pre>
  
  <p>it gives me the following exception:</p>
  
  <pre><code>SEVERE [kz.ais.user.UserBean] (default task-32) null: javax.servlet.ServletException: UT010031: Login failed
      at io.undertow.servlet.spec.HttpServletRequestImpl.login(HttpServletRequestImpl.java:426) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at kz.ais.user.UserBean.login(UserBean.java:66) [classes:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_20]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_20]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_20]
      at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_20]
      at com.sun.el.parser.AstValue.invoke(AstValue.java:275) [javax.el-3.0.0.jar:]
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) [javax.el-3.0.0.jar:]
      at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
      at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
      at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
      at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.2.6-jbossorg-4.jar:]
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.2.6-jbossorg-4.jar:]
      at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.2.6-jbossorg-4.jar:]
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.6-jbossorg-4.jar:]
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) [jsf-impl-2.2.6-jbossorg-4.jar:]
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) [jboss-jsf-api_2.2_spec-2.2.6.jar:2.2.6]
      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70) [primefaces-5.0.jar:5.0]
      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727) [undertow-core-1.0.15.Final.jar:1.0.15.Final]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20]
  </code></pre>