[jboss-user] [EJB3] - Is it possibile open an UserTransaction from a client ?

Stefano Gallina do-not-reply at jboss.com
Mon Mar 26 08:00:24 EDT 2012


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&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120326/13edb6cc/attachment-0001.html 


More information about the jboss-user mailing list