CDI Bean with @SessionScoped initializes more than once

1

I created a bean CDI with session scope (% with%). The problem is that you are going through the constructor several times, and it should be only one time while the user is logged in, correct?

I've already changed the constructor to a method ( @SessionScoped ), but it did not work.

In this way, attributes that should be initialized only once are being initialized several times, giving errors such as @PostConstruct .

I'm using CDI with JSF, PrimeFaces 6, JPA and WildFly 10.

    package br.com.transportesalvorada.security.controll;

    import java.io.IOException;
    import java.util.Collection;

    import javax.annotation.PostConstruct;
    import javax.enterprise.context.SessionScoped;
    import javax.faces.context.FacesContext;
    import javax.inject.Named;

    import org.primefaces.model.menu.MenuModel;
    import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
    import org.springframework.security.core.GrantedAuthority;

    import br.com.transportesalvorada.security.bean.util.CriaMenus;
    import br.com.transportesalvorada.security.bean.util.ManipulacaoProperties;
    import br.com.transportesalvorada.security.configall.UsuarioSistema;
    import br.com.transportesalvorada.securityadmin.util.FacesUtil;
    import java.io.Serializable;

    @Named
    @SessionScoped
    public class SecurityControllerLogado implements Serializable {

        private static final long serialVersionUID = 1L;

        private Long idLogado = 0L;
        private UsuarioSistema usuarioLogado;
        private String grupos = "";
        private MenuModel menu;
        private String versao = "";

// corpo do bean

}
    
asked by anonymous 13.09.2016 / 14:19

0 answers