PhaseListener class not found

468 Views Asked by At

good afternoon!

Always I try to deploy my .ear application in GlassFish3, I get the stack trace below referring to .war file inside .ear. I Tryed to search some solutions in several sites, but nothing help me. I got these project ready from work and don't know what can be.

Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: 
  Source Document: jndi:/server/portal_education-war-0.0.51-SNAPSHOT/WEB-INF/faces-config.xml
  Cause: Unable to find class 'br.com.portal.education.listener.FaseListener'.

My faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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"
    version="2.0">

    <navigation-rule>
        <navigation-case>
            <from-outcome>index</from-outcome>
            <to-view-id>/pages/index.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>

    <lifecycle>
        <phase-listener>br.com.portal.education.listener.FaseListener</phase-listener>
    </lifecycle>

</faces-config>

And my class 'FaseListener':

package br.com.portal.education.listener;

import java.io.IOException;
import java.io.Serializable;

import javax.faces.application.NavigationHandler;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpSession;

import br.com.portal.education.entity.GoogleUser;


public class FaseListener implements Serializable, PhaseListener {

    private static final long serialVersionUID = -4438623717276074774L;

    @Override
    public void afterPhase(PhaseEvent event) {
        FacesContext facesContext = event.getFacesContext();
        ExternalContext ec = facesContext.getExternalContext();

        String currentPage = facesContext.getViewRoot().getViewId();

        boolean isLoginPage = (currentPage.lastIndexOf("login.xhtml") > -1 || currentPage.lastIndexOf("register.xhtml") > -1);
        HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
        if (session == null) {
            session = (HttpSession) facesContext.getExternalContext().getSession(true);
            NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
            nh.handleNavigation(facesContext, null, "loginPage");
        } else {
            GoogleUser currentUser = (GoogleUser) session.getAttribute("userAuthentication");

            if (!isLoginPage && (currentUser == null || currentUser.getUser().getId() == null)) {
                // NavigationHandler nh =
                // facesContext.getApplication().getNavigationHandler();
                // nh.handleNavigation(facesContext, null, "loginPage");

                try {
                    ec.redirect(ec.getRequestContextPath() + "/login.xhtml");
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

    @Override
    public void beforePhase(PhaseEvent event) {

    }

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

}

The class is placed in: .EAR File -> .WAR File -> WEB-INF -> classes -> br -> com -> portal -> education -> listener -> FaseListener.java Class Path

0

There are 0 best solutions below