omar al kababji wrote:By default method will be Container Managed Transaction,
Specs wrote:joinTransaction method should be called on a JTA application managed EntityManager that was created outside the scope of the active transaction to associate it with the current JTA transaction.
omar al kababji wrote:i think that you are calling your method directly so there is currently no transaction.
When an EntityManager with an extended persistence context is used, the persist, remove, merge, and
refresh operations may be called regardless of whether a transaction is active. The effects of these oper-
ations will be committed to the database when the extended persistence context is enlisted in a transac-
tion and the transaction commits.
The scope of the persistence context of an application-managed entity manager is extended. It is the
responsibility of the application to manage the lifecycle of the persistence context.
Raf Szczypiorski wrote:
If you really want to provoke an exception, call flush() yourself - TransactionRequiredException on the way.
Raf Szczypiorski wrote:Can you change it to be stateless bean? See what happens.
SCJP 5 (98%) - SCBCD 5 (98%)
addCustomer 22:47:59.312
inti 22:47:59.187
Caused by: javax.persistence.TransactionRequiredException
at com.sun.enterprise.util.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:236)
at com.sun.enterprise.util.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:200)
at com.sun.enterprise.util.EntityManagerWrapper.persist(EntityManagerWrapper.java:426)
at ejb.StatelessSesssionBeanBean.addEmployee(StatelessSesssionBeanBean.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
... 17 more
Regards
Sudhakar
I did not understand how you drew the conclusion you did about transactional context. To me all this is telling me is that init ran before addCustomer. I am not sure how anything about their transactional context can be derived from this. Can you explain this a little bit.
SCJP 5 (98%) - SCBCD 5 (98%)
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|