Package org.apache.roller.weblogger.business.startup

Examples of org.apache.roller.weblogger.business.startup.StartupException


            } catch (ClassNotFoundException ex) {
                String errorMsg =
                     "ERROR: cannot load JDBC driver class [" + getJdbcDriverClass()+ "]. "
                    +"Likely problem: JDBC driver jar missing from server classpath.";
                errorMessage(errorMsg);
                throw new StartupException(errorMsg, ex, startupLog);
            }
            successMessage("SUCCESS: loaded JDBC driver class [" +getJdbcDriverClass()+ "]");
           
            if (getJdbcUsername() != null || getJdbcPassword() != null) {
                props = new Properties();
                if (getJdbcUsername() != null) props.put("user", getJdbcUsername());
                if (getJdbcPassword() != null) props.put("password", getJdbcPassword());
            }
           
        // Else attempt to locate JNDI datasource
        } else {
            String name = "java:comp/env/" + getJndiName();
            successMessage("-- Using JNDI datasource name: " + name);
            try {
                InitialContext ic = new InitialContext();
                dataSource = (DataSource)ic.lookup(name);
            } catch (NamingException ex) {
                String errorMsg =
                    "ERROR: cannot locate JNDI DataSource [" +name+ "]. "
                   +"Likely problem: no DataSource or datasource is misconfigured.";
                errorMessage(errorMsg);
                throw new StartupException(errorMsg, ex, startupLog);
            }           
            successMessage("SUCCESS: located JNDI DataSource [" +name+ "]");
        }
       
        // So far so good. Now, can we get a connection?
        try {
            Connection testcon = getConnection();
            testcon.close();
        } catch (Throwable t) {
            String errorMsg =
                "ERROR: unable to obtain database connection. "
               +"Likely problem: bad connection parameters or database unavailable.";
            errorMessage(errorMsg);
            throw new StartupException(errorMsg, t, startupLog);
        }
    }
View Full Code Here


        if (WebloggerFactory.isBootstrapped()) {
            return SUCCESS;
        }
       
        if (WebloggerStartup.getDatabaseProviderException() != null) {
            StartupException se = WebloggerStartup.getDatabaseProviderException();
            if (se.getRootCause() != null) {
                rootCauseException = se.getRootCause();
            } else {
                rootCauseException = se;
            }
            messages = se.getStartupLog();
           
            log.debug("Forwarding to database error page");
            setPageTitle("installer.error.connection.pageTitle");
            return DATABASE_ERROR;
        }  
View Full Code Here

        if (WebloggerFactory.isBootstrapped()) {
            return SUCCESS;
        }
       
        if (WebloggerStartup.getDatabaseProviderException() != null) {
            StartupException se = WebloggerStartup.getDatabaseProviderException();
            if (se.getRootCause() != null) {
                rootCauseException = se.getRootCause();
            } else {
                rootCauseException = se;
            }
            messages = se.getStartupLog();
           
            log.debug("Forwarding to database error page");
            setPageTitle("installer.error.connection.pageTitle");
            return DATABASE_ERROR;
        }  
View Full Code Here

            String name = "java:comp/env/" + jndiName;
            try {
                Context ctx = (Context) new InitialContext();
                session = (Session) ctx.lookup(name);
            } catch (NamingException ex) {
                throw new StartupException("ERROR looking up mail-session with JNDI name: " + name);
            }
        } else {
            Properties props = new Properties();
            props.put("mail.smtp.host", mailHostname);
            if (mailUsername != null && mailPassword != null) {
                props.put("mail.smtp.auth", "true");  
            }
            if (mailPort != -1) {
                props.put("mail.smtp.port", ""+mailPort);
            }
            session = Session.getDefaultInstance(props, null);
        }
       
        try {
            Transport transport = getTransport();
            transport.close();
        } catch (Throwable t) {
            throw new StartupException("ERROR connecting to mail server", t);
        }
       
    }
View Full Code Here

            } catch (ClassNotFoundException ex) {
                String errorMsg =
                     "ERROR: cannot load JDBC driver class [" + getJdbcDriverClass()+ "]. "
                    +"Likely problem: JDBC driver jar missing from server classpath.";
                errorMessage(errorMsg);
                throw new StartupException(errorMsg, ex, startupLog);
            }
            successMessage("SUCCESS: loaded JDBC driver class [" +getJdbcDriverClass()+ "]");
           
            if (getJdbcUsername() != null || getJdbcPassword() != null) {
                props = new Properties();
                if (getJdbcUsername() != null) props.put("user", getJdbcUsername());
                if (getJdbcPassword() != null) props.put("password", getJdbcPassword());
            }
           
        // Else attempt to locate JNDI datasource
        } else {
            String name = (getJndiName().indexOf(":") == -1 ? "java:comp/env/" + getJndiName() : getJndiName());
            successMessage("-- Using JNDI datasource name: " + name);
            try {
                InitialContext ic = new InitialContext();
                dataSource = (DataSource)ic.lookup(name);
            } catch (NamingException ex) {
                String errorMsg =
                    "ERROR: cannot locate JNDI DataSource [" +name+ "]. "
                   +"Likely problem: no DataSource or datasource is misconfigured.";
                errorMessage(errorMsg);
                throw new StartupException(errorMsg, ex, startupLog);
            }           
            successMessage("SUCCESS: located JNDI DataSource [" +name+ "]");
        }
       
        // So far so good. Now, can we get a connection?
        try {
            Connection testcon = getConnection();
            testcon.close();
        } catch (Throwable t) {
            String errorMsg =
                "ERROR: unable to obtain database connection. "
               +"Likely problem: bad connection parameters or database unavailable.";
            errorMessage(errorMsg);
            throw new StartupException(errorMsg, t, startupLog);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.business.startup.StartupException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.