title: EJB Stateless Initialization Pattern
body: <p>I have an EJB Stateless Session Bean. I have these requirements:</p>
  
  <ol>
  <li>This Stateless EJB should be initialized at startup</li>
  <li>The initialization code should make a transactional access to a database</li>
  </ol>
  
  <p>The problem is:</p>
  
  <ol>
  <li>@Startup is only available for @Singleton EJBs</li>
  <li>@PostConstruct annotation (at least on Websphere) doesn't have a transactional context at this point so the initialization code explode here!</li>
  </ol>
  
  <p>Possible solutions?</p>
  
  <ol>
  <li>Use a Java EE Timer but it seems to be designed for periodic execution. I want just only one execution at time zero.</li>
  <li>Use a @Singleton + @Startup EJB just for initialization purposes and inject this singleton EJB to the dependant Stateless EJBs.</li>
  </ol>
  
  <p>Question:</p>
  
  <ol>
  <li>Can any one explain how it is supposed a Stateless EJB to be initialized?  or it has no sense? (I mean, stateless EJB are supposed to not to have initialization state?)</li>
  <li>Is there any pattern out there that says use of secondary EJB @Singleton with @Startup is a good idea?</li>
  </ol>