mardi 30 juin 2015

Cannot inject bean of non-serializable type into bean of passivating scope

I'm learning Java EE 7.

I'm trying to store the user session in a @SessionScoped Backing Bean but my IDE is telling me that I have an error because "Cannot inject bean of non-serializable type into bean of passivating scope".

The @SessionScoped bean:

import negocio.Autenticacion;

import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;

@Named
@SessionScoped
public class UserSesion implements Serializable{

    @Inject
    private Autenticacion auth; // Error by IDE


}

@Stateless EJB code:

import modelo.Usuario;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.security.MessageDigest;

@Stateless
public class AutenticacionBean implements Autenticacion{

    @PersistenceContext(unitName = "Banco-PU")
    private EntityManager em;
...

Why can't I Inject the EJB in the backing bean?

Aucun commentaire:

Enregistrer un commentaire