This is the way to run the initialization code from EJB:
@Singleton @Startup public class MigrationManager { @PostConstruct public void migrate() {
For this you do not need a separate application (as indicated in the comment above).
An EntityManager is created by tape, because until you enter the EntityManager in some other startup code, this should enable you to update the database schema before the EntityManager actually enters the database.
By the way, for migrating a database schema, I would recommend Liquibase , which can be called by ServletContextListener .
source share