-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: I have a little problem with EntityManager persist
PostPosted: Wed Feb 10, 2010 9:14 pm 
Newbie

Joined: Wed Feb 10, 2010 8:42 pm
Posts: 3
I'm working on a small application with seam framework and I'm having trouble when I use the command entityManager.persist (usuario);
the server returns NullPointerException in method usuarioAction.salvarUsuario() why?

20:33:05,018 ERROR [application] java.lang.NullPointerException
javax.faces.el.EvaluationException: java.lang.NullPointerException



Myclass UsuarioAction.java

import java.util.List;
import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage.Severity;

import br.odebrecht.entity.Usuario;

@Name("usuarioAction")
@Scope(ScopeType.CONVERSATION)
public class UsuarioAction {

@In(required=false)
@Out(required=false)
private Usuario usuario;

@In
private EntityManager entityManager;

@Out
FacesMessages facesMessages;

@DataModel
List<Usuario> listaUsuario;

@DataModelSelection
@Out(required=false)
Usuario usuarioSelecionado;

public void salvarUsuario(){
try {
entityManager.persist(usuario); //Here NullPointerException happens

} catch (Exception e) {
facesMessages.add(Severity.ERROR,"Erro ao salvar informações!!! ");
}
facesMessages.add(Severity.INFO,"Operação realizada com sucesso!!!");
}
}



usuario.xhtml call the salvarUsuario method

<h:commandButton id="salvar" action="#{usuarioAction.salvarUsuario}" value="Salvar" />


Someone help me ..

thanks for attention


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.