@Override
public Order startOrder(Map<Article, Integer> article, String name, String surname, String street, String postal, String city, String email) throws ApplicationException {
CustomerDTO customer = new CustomerDTO(name, surname, street,postal, city, email);
try {
em.persist(customer);
} catch (ConstraintViolationException cvex) {
violationException(cvex);
} catch (Exception e) {
sctx.setRollbackOnly();
throw new ApplicationException("", "the order-process failed");
}
long customernr = customer.getCustomernr();
return startOrder(article, customernr);
}
So I am using Java EE now for the first time. I have a distributed application and this is a method of my session bean called "ShopDAO". This is in my session bean too:
@PersistenceContext(unitName = "ShopDAOPU")
private EntityManager em;
@Resource
private SessionContext sctx;
Furthermore, my session bean class is declared with the following annotations:
@DataSourceDefinition(name = "java:global/jdbc/shopdao",
className = "org.apache.derby.jdbc.ClientXADataSource",
serverName = "localhost",
databaseName = "DVI-P1;create=true",
user = "dvi",
password = "psswrd",
maxIdleTime = 600
)
@Stateless
@Local(ShopDAOLocal.class)
Everytime when I try to send an order, I get the message "the order-process failed". So I guess that's because the entity manager couldn't persist the customer. But why?
Aucun commentaire:
Enregistrer un commentaire