Problema com EJB 3.0 / Persistencia

0 respostas
vjfenix

Ola Pessoal!!

Estou fazendo um exemplo para entender EJB / Persistencia porem esta me dando o erro abaixo e nao consegui resolver, se alguem puder me dar uma ajuda:

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: #{EntityJSFBackBean.addCustomer}: javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
root cause

javax.faces.FacesException: #{EntityJSFBackBean.addCustomer}: javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
root cause

javax.faces.el.EvaluationException: javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
root cause

javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_01 logs.

Sessao

@PersistenceContext
    EntityManager em;

    public Customer addNewCustomer(final Customer customer) {

        em.persist(customer);
        
        return customer;
    }

BackBean

@EJB
    private MyEntitySessionLocal myEntitySessionLocal;
    private Customer customer = new Customer();

    /** Creates a new instance of EntityJSFBackBean */
    public EntityJSFBackBean() {
    }

    public String addCustomer() {
        myEntitySessionLocal.addNewCustomer(customer);
        return "gotoHome";
    }

    public List<Customer> getCustumers() {

        return getMyEntitySessionLocal().getCustomers();
    }

    public MyEntitySessionLocal getMyEntitySessionLocal() {
        return myEntitySessionLocal;
    }

    public void setMyEntitySessionLocal(MyEntitySessionLocal myEntitySessionLocal) {
        this.myEntitySessionLocal = myEntitySessionLocal;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }
}

JSP

<f:view>
            <h2>Adding a Customer</h2>
            <h:messages/>
            <h:form>
                Id:   <h:inputText value="#{EntityJSFBackBean.customer.customerId}"/><br/>
                Name: <h:inputText value="#{EntityJSFBackBean.customer.name}"/><br/>
                ZIP : <h:inputText value="#{EntityJSFBackBean.customer.zip}"/><br/>
                
                <h:commandButton value="Add" action="#{EntityJSFBackBean.addCustomer}"/>
            </h:form>   
            
        </f:view>
Criado 23 de novembro de 2008
Respostas 0
Participantes 1