0
I am trying to create a session for a login using Java, vRaptor, Hibernate, Angularjs.
But when the session will be created I get this exception (500 (Internal Server Error
)).
This is my session class using vRaptor:
@SessionScoped
@Any public class Loginmodel Implements Serializable { private administrator;
public static void LoginModel(String[] arg) {
}
public void login(Administrador administrador) {
this.administrador = administrador;
}
public boolean isLogado() {
return administrador != null;
}
public Administrador getLogado() {
return administrador;
}
public void setLogado(Administrador administrador) {
this.administrador = administrador;
}
public void logout() {
this.administrador = null;
}
And in my controller I have the method that checks and creates the session :
@Consumes("application/json")
@Post("/verifica-login")
public void verificaLogin(String email, String senha) {
try {
Administrador administrador;
administrador = administradorRepository.login(email, senha);
//Até essa parte esta tudo certo, o administrador ja foi validado
// e já foi carregado no objeto administrador, mas quando o comando
// abaixo (if) é executado eu recebo a exceção.
if (administrador != null) {
loginModel.login(administrador);
}
result.use(Results.json()).withoutRoot().from(administrador).serialize();
} catch (Exception e) {
result.use(Results.json()).withoutRoot().from(e.getMessage()).serialize();
}
}
I would like to know what I am doing because I read some documentation and followed some tutorials and apparently it is right, but my lack of experience does not help in these KKK hours. I was following an example of Caelum.
Obs. I don’t know what this @Any annotation is for, but I was asking it or @Default to work, the Caelum tutorial asks to add the @Component annotation, but this annotation does not have any import of vraptor or anything like that.