Stefano Gallina [
https://community.jboss.org/people/warxsg] created the discussion
"Is it possibile open an UserTransaction from a client ?"
To view the discussion, visit:
https://community.jboss.org/message/726282#726282
--------------------------------------------------------------
Hi all,
I have a Session bean:
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
The session bean calls an entity bean and save the name and the surname in table called
Customer
I wanted to manage the transaction from a Java Client so I wrote a Java the following
code :
userTx = (UserTransaction) ctx.lookup("UserTransaction");
userTx.begin();
customerCreation.createSimpleCustomer("TestName", "TestSurname");
userTx.commit();
When I run my class I have the error:
[STDERR] javax.persistence.TransactionRequiredException: EntityManager must be access
within a transaction
[STDERR] at
org.jboss.jpa.deployment.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:155)
[STDERR] at
org.jboss.jpa.tx.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:186)
[STDERR] at
com.allianzppu.b2x.CustomerCreation.createSimpleCustomer(CustomerCreation.java:47)
If I manage the transaction inside the mehod of my session bean everything works.
Any suggestion ?
Cheers.
warxsg
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/726282#726282]
Start a new discussion in EJB3 at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]