I'm not a professional and trying to develop app with jsf. I've already made several pages, database connectivity with hibernate etc.
I have just added authentication using wildfly 13 elytron security system using form-based programmatic login with DB realm (I use mysql database).
After that I have encountered problem with page navigation (before this worked perfectly fine):
1) After launching app there is a login page: http://127.0.0.1:8080/NNManagement-0.0.1-SNAPSHOT/ 2) After successful login there should be Team.xhtml page displayed (this is what login method returns) i.e. http://127.0.0.1:8080/NNManagement-0.0.1-SNAPSHOT/resources/views/Team.xhtml. Instead there is something strange - I've got url like login page: http://127.0.0.1:8080/NNManagement-0.0.1-SNAPSHOT/Login.xhtml but the content is like Team.xhtml but not working really i.e. apart from losing styles, all the links responsible for navigation do not work - they do not redirect to specific pages but they reload this login page again and again.
Still if I paste the correct address i.e. http://127.0.0.1:8080/NNManagement-0.0.1-SNAPSHOT/resources/views/Team.xhtml everything works well.
WebContent structure is like:
- resources - styles
content.css header.css 
- views
Header.xhtml Network.xhtml Team.xhtml Tasks.xhtml 
 
- styles
- WEB-INF - web.xml
- jboss-web.xml
- beans.xml
 
- Login.xhtml
- loginError.xhtml
LoginBean.java
public class LoginBean{
    private String userName;
    private String password;
    public String login() {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        try {
            request.login(getUserName(), getPassword());
            System.out.println("Trying to login "+ getUserName() + " " + getPassword());
        }catch(ServletException e){
            System.out.println(e);
            context.addMessage(null, new FacesMessage("Login failed " + e));
            return "resources/loginError.xhtml";
        }
        return "resources/views/Team.xhtml";
    }
Login.xhtml
                        <div>
                            <h:outputLabel for="userName" value="User"/>
                            <h:inputText id="userName" value="#{loginBean.userName}"
                                         required="true"
                                         requiredMessege="Please enter username"
                                         class="form-control"/>
                        </div>
                        <div>
                            <h:outputLabel for="password" value="Password"/>
                            <h:inputSecret id="password" value="#{loginBean.password}"
                                           required="true"
                                           requiredMessage="Please enter password"
                                           class="form-control"/>
                        </div>
                        <div>
                            <h:commandButton action="#{loginBean.login}" value="Login"  class="btn btn-default"/>
                        </div>
web.xml
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>Login.xhtml</welcome-file>
    </welcome-file-list>
     <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>web-security-domain</realm-name>
        <form-login-config>
            <form-login-page>/Login.xhtml</form-login-page>
            <form-error-page>/loginError.xhtml</form-error-page>
        </form-login-config>
     </login-config>
Navigation links that does no work in Header.xhtml
    <h:form>
        <ul>
            <li><a class = "#{view.viewId eq '/resources/views/Tasks.xhtml' ? 'active' : ''}" href="Tasks.xhtml">Zadania</a></li>
            <li><a class = "#{view.viewId eq '/resources/views/Network.xhtml' ? 'active' : ''}" href="Network.xhtml">Sieć</a></li>
            <li><a class = "#{view.viewId eq '/resources/views/Team.xhtml' ? 'active' : ''}" href="Team.xhtml">Zespół</a></li>
            <li><a class = "#{view.viewId eq '/resources/Login.xhtml' ? 'active' : ''}" outcome="resources/views/Login.xhtml" jsf:action="#{loginBean.logout()}">Logout</a></li>
        </ul>
    </h:form>
 
    