@Override
    public void contextInitialized(ServletContextEvent sce) {
        logger.info("Initialize JdbcRealm database");
        Connection cnn = null;
        try {
            if (dataSource == null) {
                throw new IllegalStateException("DataSource not injected, verify in web.xml that 'metadata-complete' is not set to 'true'");
            }

            cnn = dataSource.getConnection();

            testDatabaseConnectivity(cnn);
            createTablesIfNotExist(cnn);

            insertUserIfNotExists("john", "doe", "user", cnn);

            insertUserIfNotExists("cloudbees", "beescloud", "user", cnn);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Exception starting app", e);
        } finally {
            closeQuietly(cnn);
        }
    }