Can anyone confirm/deny that entityManager cannot be used in @Startup components while hbm2ddl is being used?
If you're using an EntityManagerFactory component (i.e., you're not using the app server's EMF), then the hbm2ddl is run by entityManagerFactory's @Create method. So your @Startup component depends on the database, then you can denote the dependency in the annotation:
and your component's @Create method will be run afterwards.
However, instead of using an application-scope/@Startup component, I'd recommend using an observer of the org.jboss.seam.postInitialization event. It's a bit cleaner, IMO.
Your suggestion with "depend" annotation totally worked. And, also, it helped me with another issue I was having:
I'll definitely give the observer a try, never used any observers before.