Search in sources :

Example 1 with ForumStartupException

use of net.jforum.exceptions.ForumStartupException in project jforum2 by rafaelsteil.

the class JForumBaseServlet method startApplication.

protected void startApplication() {
    try {
        SystemGlobals.loadQueries(SystemGlobals.getValue(ConfigKeys.SQL_QUERIES_GENERIC));
        SystemGlobals.loadQueries(SystemGlobals.getValue(ConfigKeys.SQL_QUERIES_DRIVER));
        String filename = SystemGlobals.getValue(ConfigKeys.QUARTZ_CONFIG);
        SystemGlobals.loadAdditionalDefaults(filename);
        ConfigLoader.createLoginAuthenticator();
        ConfigLoader.loadDaoImplementation();
        ConfigLoader.listenForChanges();
        ConfigLoader.startSearchIndexer();
        ConfigLoader.startSummaryJob();
    } catch (Exception e) {
        throw new ForumStartupException("Error while starting JForum", e);
    }
}
Also used : ForumStartupException(net.jforum.exceptions.ForumStartupException) ServletException(javax.servlet.ServletException) ForumStartupException(net.jforum.exceptions.ForumStartupException)

Example 2 with ForumStartupException

use of net.jforum.exceptions.ForumStartupException in project jforum2 by rafaelsteil.

the class JForum method init.

/**
	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
	 */
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    super.startApplication();
    // Start database
    isDatabaseUp = ForumStartup.startDatabase();
    try {
        Connection conn = DBConnection.getImplementation().getConnection();
        conn.setAutoCommit(!SystemGlobals.getBoolValue(ConfigKeys.DATABASE_USE_TRANSACTIONS));
        // Try to fix some MySQL problems
        MySQLVersionWorkarounder dw = new MySQLVersionWorkarounder();
        dw.handleWorkarounds(conn);
        // Continues loading the forum
        JForumExecutionContext ex = JForumExecutionContext.get();
        ex.setConnection(conn);
        JForumExecutionContext.set(ex);
        // Init general forum stuff
        ForumStartup.startForumRepository();
        RankingRepository.loadRanks();
        SmiliesRepository.loadSmilies();
        BanlistRepository.loadBanlist();
    } catch (Throwable e) {
        e.printStackTrace();
        throw new ForumStartupException("Error while starting jforum", e);
    } finally {
        JForumExecutionContext.finish();
    }
}
Also used : MySQLVersionWorkarounder(net.jforum.dao.MySQLVersionWorkarounder) Connection(java.sql.Connection) ForumStartupException(net.jforum.exceptions.ForumStartupException)

Example 3 with ForumStartupException

use of net.jforum.exceptions.ForumStartupException in project jforum2 by rafaelsteil.

the class JForumBaseServlet method init.

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
        String appPath = config.getServletContext().getRealPath("");
        debug = "true".equals(config.getInitParameter("development"));
        DOMConfigurator.configure(appPath + "/WEB-INF/log4j.xml");
        logger.info("Starting JForum. Debug mode is " + debug);
        ConfigLoader.startSystemglobals(appPath);
        ConfigLoader.startCacheEngine();
        // Configure the template engine
        Configuration templateCfg = new Configuration();
        templateCfg.setTemplateUpdateDelay(2);
        templateCfg.setSetting("number_format", "#");
        templateCfg.setSharedVariable("startupTime", new Long(new Date().getTime()));
        // Create the default template loader
        String defaultPath = SystemGlobals.getApplicationPath() + "/templates";
        FileTemplateLoader defaultLoader = new FileTemplateLoader(new File(defaultPath));
        String extraTemplatePath = SystemGlobals.getValue(ConfigKeys.FREEMARKER_EXTRA_TEMPLATE_PATH);
        if (StringUtils.isNotBlank(extraTemplatePath)) {
            // An extra template path is configured, we need a MultiTemplateLoader
            FileTemplateLoader extraLoader = new FileTemplateLoader(new File(extraTemplatePath));
            TemplateLoader[] loaders = new TemplateLoader[] { extraLoader, defaultLoader };
            MultiTemplateLoader multiLoader = new MultiTemplateLoader(loaders);
            templateCfg.setTemplateLoader(multiLoader);
        } else {
            // An extra template path is not configured, we only need the default loader
            templateCfg.setTemplateLoader(defaultLoader);
        }
        ModulesRepository.init(SystemGlobals.getValue(ConfigKeys.CONFIG_DIR));
        this.loadConfigStuff();
        if (!this.debug) {
            templateCfg.setTemplateUpdateDelay(3600);
        }
        JForumExecutionContext.setTemplateConfig(templateCfg);
    } catch (Exception e) {
        throw new ForumStartupException("Error while starting JForum", e);
    }
}
Also used : MultiTemplateLoader(freemarker.cache.MultiTemplateLoader) Configuration(freemarker.template.Configuration) TemplateLoader(freemarker.cache.TemplateLoader) FileTemplateLoader(freemarker.cache.FileTemplateLoader) MultiTemplateLoader(freemarker.cache.MultiTemplateLoader) FileTemplateLoader(freemarker.cache.FileTemplateLoader) ForumStartupException(net.jforum.exceptions.ForumStartupException) File(java.io.File) Date(java.util.Date) ServletException(javax.servlet.ServletException) ForumStartupException(net.jforum.exceptions.ForumStartupException)

Aggregations

ForumStartupException (net.jforum.exceptions.ForumStartupException)3 ServletException (javax.servlet.ServletException)2 FileTemplateLoader (freemarker.cache.FileTemplateLoader)1 MultiTemplateLoader (freemarker.cache.MultiTemplateLoader)1 TemplateLoader (freemarker.cache.TemplateLoader)1 Configuration (freemarker.template.Configuration)1 File (java.io.File)1 Connection (java.sql.Connection)1 Date (java.util.Date)1 MySQLVersionWorkarounder (net.jforum.dao.MySQLVersionWorkarounder)1