• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

A Timer cannot be created in @PostConstruct using BMT ?

 
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The objective is to create a Timer in @PostConstruct of a Stateless bean using BMT:


I got this:


Warning: A system exception occurred during an invocation on EJB StatelessSessionBeanA method public void com.ivan.scbcd6.StatelessSessionBeanA.method1()
javax.ejb.EJBException: Stateless SessionBean method returned without completing transaction
at com.sun.ejb.containers.BaseContainer.checkExceptionBeanMgTx(BaseContainer.java:4973)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4844)

 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But if I create the Timer in a business method in the above bean, the timer can be created.


I understand the fact that @PostConstruct should be called in an unspecified transaction context, but the user transaction should suspend any transaction.
 
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you create the timer without a transaction in the @PostConstruct method, does that work?
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, the transaction management is Container Managed Transaction.
I tried to create the time in @PostConstruct method.
For stateless bean the @PostConstruct method is implemented in an unspecified transaction context and the timer must be created in a transaction with attribute (REQUIRED or REQUIRED_NEW).
The timer is not created.



Info: *** StatelessSessionBeanA - initialized
Severe: EJB5070: Exception creating stateless session bean : [StatelessSessionBeanA]
Warning: A system exception occurred during an invocation on EJB StatelessSessionBeanA method public void com.ivan.scbcd6.StatelessSessionBeanA.method1()
javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:454)
...
Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
...
Caused by: javax.ejb.CreateException: Could not create stateless EJB
...
Caused by: java.lang.IllegalStateException: EJB Timer method calls cannot be called in this context
.....


 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the timer can be created with a singleton bean.
The timer is created within a user managed transaction in @PostConstruct.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!