Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:38:25+00:00 2026-05-30T21:38:25+00:00

I have a PhaseListener and does not work. But in the computer of my

  • 0

I have a PhaseListener and does not work. But in the computer of my co-worker if it works.

I use netbeans 6.8 With Glassfish 2.1 and Windows 32 bits

The PhaseListener:

package mx.udg.cgti.seguridad.listener;

import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.NavigationHandler;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseListener;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import mx.udg.cgti.seguridadcore.negocio.ProcesosCNLocal;

public class SeguridadCorePhaseListener implements PhaseListener {

    public SeguridadCorePhaseListener() {
    }

    public void beforePhase(PhaseEvent pe) {
        System.out.println("beforePhase");
    }

    public void afterPhase(PhaseEvent pe) {
        System.out.println("afterPhase");
        if (pe.getPhaseId().equals(PhaseId.RESTORE_VIEW)) {

            if (pe.getFacesContext() != null) {

                String pagina = pe.getFacesContext().getViewRoot().getViewId();
                if (!"/Inicio.xhtml".equalsIgnoreCase(pagina) && !"/Login.xhtml".equalsIgnoreCase(pagina) && pagina.contains(".xhtml")) {
                    loggedIn();
                }
            }
        }
    }

    private void loggedIn() {
        String pagina = "";
        Long token = obtenToken();
        if (token != null) {
            String result = "";
            result = lookupProcesosCNLocal().getSesionActiva(token);
            if ("".equalsIgnoreCase(result)) {
                result = null;
            }
 //           System.out.println("RESULT " + result);
            if (result == null) {
                pagina = new String("sessionTimeout");
            }
        } else {
            pagina = new String("sinSession");
        }
 //       System.out.println(" PAGINA :- " + pagina + " TOKEN " + token);
        if (!pagina.equalsIgnoreCase("")) {
 //          System.out.println("REGLAS DE NAVEGACION TRABAJANDO HACIA  " + pagina);
            FacesContext fc = FacesContext.getCurrentInstance();
            NavigationHandler nh = fc.getApplication().getNavigationHandler();
            nh.handleNavigation(fc, null, pagina);
            fc.renderResponse();
        }

    }

    private Long obtenToken() {
        Long token = null;
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
        Object t = request.getAttribute("token");
        if (t == null) {
            Object obj=null;
            if(session != null){
                obj = session.getAttribute("token");
                if(obj == null){
                    obj = request.getParameter("token");
                }
            }else{
                obj = request.getParameter("token");
            }
            if (obj != null) {
                if (obj != null && !"".equalsIgnoreCase(obj.toString())) {
                    token = Long.parseLong(obj.toString());
                }
            }
        } else {
            token = Long.parseLong(t.toString());
        }
        if (token != null) {
            request.setAttribute("token", token);
            if(session == null){
                session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
            }
            session.setAttribute("token", token);
        }
        return token;
    }

    public PhaseId getPhaseId() {
        return PhaseId.RESTORE_VIEW;
    }

    private ProcesosCNLocal lookupProcesosCNLocal() {
        try {
            Context c = new InitialContext();
            return (ProcesosCNLocal) c.lookup("java:comp/env/ProcesosCN");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="2.0"
              xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

    <navigation-rule>
        <from-view-id>/*</from-view-id>
        <navigation-case>
            <from-outcome>logear</from-outcome>
            <to-view-id>/Login.xhtml</to-view-id>
            <redirect>1</redirect>
        </navigation-case>
        <navigation-case>
            <from-outcome>sessionTimeout</from-outcome>
            <to-view-id>/LoginError.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>sinSession</from-outcome>
            <to-view-id>/LoginError.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>    
    <application>
        <message-bundle>
            mx.udg.cgti.seguridad.boundle.MiBoundle
        </message-bundle>
    </application>
    <lifecycle>
        <phase-listener>mx.udg.cgti.seguridad.listener.SeguridadCorePhaseListener</phase-listener>
    </lifecycle>
    <validator>
        <validator-id>validaComboRequerido</validator-id>
        <validator-class>mx.udg.cgti.seguridad.validator.ValidaComboRequerido</validator-class>
    </validator>
    <converter>
        <converter-id>tipoUsuario</converter-id>
        <converter-class>mx.udg.cgti.ln.convertidor.TipoUsuarioConverter</converter-class>
    </converter>
    <converter>
        <converter-id>Usuario</converter-id>
        <converter-class>mx.udg.cgti.ln.convertidor.UsuarioConverter</converter-class>
    </converter>
    <converter>
        <converter-id>Rol</converter-id>
        <converter-class>mx.udg.cgti.ln.convertidor.RolConverter</converter-class>
    </converter>
    <converter>
        <converter-id>Permiso</converter-id>
        <converter-class>mx.udg.cgti.ln.convertidor.PermisoConverter</converter-class>
    </converter>
    <converter>
        <converter-id>UnidadOrganizacional</converter-id>
        <converter-class>mx.udg.cgti.ln.convertidor.UnidadOrganizacionalConverter</converter-class>
    </converter>

</faces-config>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:38:26+00:00Added an answer on May 30, 2026 at 9:38 pm

    Apparently you’ve another version of exactly the same class somewhere in the classpath which got precedence in classloading over the one included in the WAR.

    That can be inside the /lib folder of the server itself, or inside the /lib or /lib/ext folders of the installed JRE which is used by the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have 2 questions : A computer with 32-bit address uses 2-level page table (9
Have a SQL problem, adding this model all works correctly, the problem is in
have been using no DOCTYPE but rather simply starting with <html> as per HTML5
I have a phaseListener and more then one filter. I want to know if
I have a PhaseListener which listens on phaseId RENDER_RESPONSE. This faceListener calls this method:
I have written a PhaseListener in which I am checking for the Validations phase.
I have this PhaseListner: public class CheckAccessInterceptor implements PhaseListener { private static final long
I have a composite component: <cc:interface componentType=com.example.MyComponent> <!-- ... --> </cc:interface> <cc:implementation> <f:phaseListener binding=#{cc}/>
Have you managed to get Aptana Studio debugging to work? I tried following this,
In my JSF2 application I have a phaselistener that needs to be executed before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.