Problème d'authentification application j2ee

Fermé
momy2014 Messages postés 9 Date d'inscription vendredi 2 mai 2014 Statut Membre Dernière intervention 12 mai 2015 - 12 mai 2015 à 16:17
Bonjour,
Aider moi SVP toujours j'aurais " Compte Intouvable" lorsque je saisie le login et le mot de passe.


@Stateless
@LocalBean
public class AdminService implements AdminServiceRemote, AdminServiceLocal {


@PersistenceContext
EntityManager entityManager;
public AdminService() {


}
@Override
public Administrateur authentAdmin(String login, String password) {
try{

Query query=entityManager.createQuery("select a from Administrateur where a.login=:login and a.password=:password").setParameter("login", login).setParameter("password", password);
return (Administrateur) query.getSingleResult();
}catch (Exception exception){
exception.printStackTrace();
return null;
}


}

Dans le controller
@ManagedBean
@RequestScoped
public class AuthentificationController {

Administrateur admin=new Administrateur();
@EJB
AdminServiceLocal adminServiceLocal;


private String login;
private String password;


public String authentificateAdmin(){
try {
if (adminServiceLocal.authentAdmin(login, password)!=null)
{

FacesContext.getCurrentInstance().getExternalContext().redirect("http://localhost:8383/ChangeWebb/faces/MenuTrigger.xhtml");
return"OK";
}else {

FacesMessage facesMessage =new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "Compte introuvable");
FacesContext.getCurrentInstance().addMessage(null, facesMessage);
return "";
}

} catch (Exception e) {

e.printStackTrace();
return null;
}
//getters & Setters

code Xhtml

<p:panel id="id22" header="Authentification "/>

<p:panelGrid columns="2" >

<p:outputLabel value="Login "></p:outputLabel>
<p:inputText
value="#{authentificationController.login}" />
<p:outputLabel value="Password" />
<p:password value="#{authentificationController.password}"></p:password>


</p:panelGrid>
<p:commandButton value="S'authentifier" actionListener="#{authentificationController.authentificateAdmin()}" update="msgs"/>
<p:messages id="msgs" showSummary="true" showDetail="true" globalOnly="true"></p:messages>