0 Replies Latest reply on Mar 26, 2012 8:00 AM by Steven Zoster

    Is it possibile open an UserTransaction from a client ?

    Steven Zoster Newbie

      Hi all,


      I have a Session 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");


          customerCreation.createSimpleCustomer("TestName", "TestSurname");




      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 ?