• 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

A Timer cannot be created in @PostConstruct using BMT ?

 
Ranch Hand
Posts: 1869
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: 1869
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: 3325
298
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: 1869
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: 1869
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.

 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic