Mark: it was not a question, it works :p SessionContext is usable in the @PostConstruct so this is doable.
here is a sample https://github.com/rmannibucau/JeBlog/blob/master/src/main/java/com/github/rmannibucau/blog/init/DBSetup.java *Romain Manni-Bucau* *Twitter: @rmannibucau <https://twitter.com/rmannibucau>* *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau* *Github: https://github.com/rmannibucau* 2013/10/23 Mark Struberg <[email protected]> > Romain, I fear this will not work. > > > Please note that the commons-annotation spec defines that @PostConstruct > methods must be invoked _before_ the instance is made available. > > > LieGrue, > strub > > > > > ----- Original Message ----- > > From: Romain Manni-Bucau <[email protected]> > > To: "[email protected]" <[email protected]> > > Cc: OpenEJB Users <[email protected]> > > Sent: Wednesday, 23 October 2013, 11:15 > > Subject: Re: @Async call blocks in @PostConstruct > > > > Hi > > > > to do so simply inject the sessioncontext get the business facade (on > > yourself) to invoke the @Async method. > > > > PostContruct are not async by default AFAIK > > > > *Romain Manni-Bucau* > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>* > > *Blog: > > **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau* > > *Github: https://github.com/rmannibucau* > > > > > > > > > > 2013/10/23 zmirc <[email protected]> > > > >> Hi! > >> > >> Shouldn't async methods not block even if they are called in > >> @PostConstruct? > >> Here is the sample code, which blocks if ran in Tomee 1.6.0 2013.10.23 > / 05 > >> > >> import java.util.logging.Level; > >> import java.util.logging.Logger; > >> import javax.annotation.PostConstruct; > >> import javax.ejb.Asynchronous; > >> import javax.ejb.Singleton; > >> import javax.ejb.Startup; > >> > >> @Singleton > >> @Startup > >> @Asynchronous > >> public class Async { > >> > >> @PostConstruct > >> private void init() { > >> // pretending to initialize, then to call one of the methods > >> doingHardWork(); > >> } > >> > >> public void doingHardWork() { > >> System.out.println("Working hard START"); > >> try { > >> Thread.sleep(1000 * 10); > >> } catch (InterruptedException ex) { > >> Logger.getLogger(Async.class.getName()).log(Level.SEVERE, > >> null, ex); > >> } > >> System.out.println("Working hard END"); > >> } > >> > >> } > >> > >> > >> > >> -- > >> View this message in context: > >> > > > http://openejb.979440.n4.nabble.com/Async-call-blocks-in-PostConstruct-tp4665703.html > >> Sent from the OpenEJB User mailing list archive at Nabble.com. > >> > > >
