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:
[quote]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.
[/quote]
Sessao
[code]@PersistenceContext
EntityManager em;
public Customer addNewCustomer(final Customer customer) {
em.persist(customer);
return customer;
}[/code]
BackBean
[code]@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;
}
}[/code]
JSP
[code]<f:view>
Adding a Customer
<h:messages/>
<h:form>
Id: <h:inputText value="#{EntityJSFBackBean.customer.customerId}"/>
Name: <h:inputText value="#{EntityJSFBackBean.customer.name}"/>
ZIP : <h:inputText value="#{EntityJSFBackBean.customer.zip}"/>
<h:commandButton value="Add" action="#{EntityJSFBackBean.addCustomer}"/>
</h:form>
</f:view>
[/code]