[jboss-user] [Beginner's Corner] - Re: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

Wolf-Dieter Fink do-not-reply at jboss.com
Tue Aug 28 08:05:16 EDT 2012


Wolf-Dieter Fink [https://community.jboss.org/people/wdfink] created the discussion

"Re: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()"

To view the discussion, visit: https://community.jboss.org/message/756438#756438

--------------------------------------------------------------
In your Bean you have only the annotation + at Stateless+ in this case the transaction is container managed (CMT).
If you want to control the Tx demarcation you should add + at TransactionManagement(TransactionManagementType.BEAN)+
+
+
If you want only a Tx for your method I recommend to use CMT and add + at TransactionAttribute(TransactionAttributeType.REQUIRED)+ in that case the container will do all the work.

Your method can be look like:
    @Override
    *public* *void* savePrivato(String nome , String cognome) {
        Privato pr = *new* Privato();
        pr.setNome(nome);pr.setCognome(cognome);
 
        em.persist(pr);
 
        System.out.println("Utente Salvato");
    }
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/756438#756438]

Start a new discussion in Beginner's Corner at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120828/460d23e2/attachment-0001.html 


More information about the jboss-user mailing list