Search in sources :

Example 76 with LifecycleException

use of org.apache.catalina.LifecycleException in project Payara by payara.

the class FileLogger method start.

// ------------------------------------------------------ Lifecycle Methods
/**
 * Prepare for the beginning of active use of the public methods of this
 * component.  This method should be called after <code>configure()</code>,
 * and before any of the public methods of the component are utilized.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
public void start() throws LifecycleException {
    // Validate and update our current component state
    if (started)
        throw new LifecycleException(rb.getString(LogFacade.FILE_LOGGER_STARTED));
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;
    super.start();
}
Also used : LifecycleException(org.apache.catalina.LifecycleException)

Example 77 with LifecycleException

use of org.apache.catalina.LifecycleException in project tomcat-cluster-redis-session-manager by ran-jit.

the class SessionManager method startInternal.

/**
 * {@inheritDoc}
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    super.startInternal();
    super.setState(LifecycleState.STARTING);
    boolean initializedValve = false;
    Context context = getContextIns();
    for (Valve valve : context.getPipeline().getValves()) {
        if (valve instanceof SessionHandlerValve) {
            this.handlerValve = (SessionHandlerValve) valve;
            this.handlerValve.setSessionManager(this);
            initializedValve = true;
            break;
        }
    }
    if (!initializedValve)
        throw new LifecycleException("Session handling valve is not initialized..");
    initialize();
    log.info("The sessions will expire after " + (getSessionTimeout(null)) + " seconds.");
    context.setDistributable(true);
}
Also used : Context(org.apache.catalina.Context) SessionContext(tomcat.request.session.SessionContext) LifecycleException(org.apache.catalina.LifecycleException) Valve(org.apache.catalina.Valve)

Example 78 with LifecycleException

use of org.apache.catalina.LifecycleException in project Payara by payara.

the class SetParentClassLoaderRule method load.

/**
 * Start a new server instance.
 */
public void load() {
    initDirs();
    // Before digester - it may be needed
    initNaming();
    // Create and execute our Digester
    Digester digester = createStartDigester();
    long t1 = System.currentTimeMillis();
    Exception ex = null;
    InputSource inputSource = null;
    InputStream inputStream = null;
    File file = null;
    try {
        file = configFile();
        inputStream = new FileInputStream(file);
        inputSource = new InputSource("file://" + file.getAbsolutePath());
    } catch (Exception e) {
        ;
    }
    if (inputStream == null) {
        try {
            inputStream = getClass().getClassLoader().getResourceAsStream(getConfigFile());
            inputSource = new InputSource(getClass().getClassLoader().getResource(getConfigFile()).toString());
        } catch (Exception e) {
            ;
        }
    }
    // Alternative: don't bother with xml, just create it manually.
    if (inputStream == null) {
        try {
            inputStream = getClass().getClassLoader().getResourceAsStream("server-embed.xml");
            inputSource = new InputSource(getClass().getClassLoader().getResource("server-embed.xml").toString());
        } catch (Exception e) {
            ;
        }
    }
    if (inputStream == null && file != null) {
        String msg = MessageFormat.format(rb.getString(LogFacade.CANNOT_LOAD_SERVER_XML_EXCEPTION), file.getAbsolutePath());
        log.log(Level.WARNING, msg);
        return;
    }
    if (inputStream != null) {
        try {
            inputSource.setByteStream(inputStream);
            digester.push(this);
            digester.parse(inputSource);
        } catch (Exception e) {
            log.log(Level.WARNING, LogFacade.CATALINA_START_WARNING_EXCEPTION, e);
            return;
        } finally {
            try {
                inputStream.close();
            } catch (IOException ioe) {
            }
        }
    }
    // Start the new server
    if (server instanceof Lifecycle) {
        try {
            server.initialize();
        } catch (LifecycleException e) {
            log.log(Level.SEVERE, LogFacade.CATALINA_START_SEVERE_EXCEPTION, e);
        }
    }
    if (log.isLoggable(Level.INFO)) {
        long t2 = System.currentTimeMillis();
        String msg = MessageFormat.format(rb.getString(LogFacade.INIT_PROCESSED_EXCEPTION), (t2 - t1));
        log.log(Level.INFO, msg);
    }
}
Also used : InputSource(org.xml.sax.InputSource) LifecycleException(org.apache.catalina.LifecycleException) Digester(org.apache.tomcat.util.digester.Digester) Lifecycle(org.apache.catalina.Lifecycle) LifecycleException(org.apache.catalina.LifecycleException)

Aggregations

LifecycleException (org.apache.catalina.LifecycleException)78 Lifecycle (org.apache.catalina.Lifecycle)23 IOException (java.io.IOException)18 NamingException (javax.naming.NamingException)12 MalformedURLException (java.net.MalformedURLException)11 Container (org.apache.catalina.Container)11 File (java.io.File)10 Realm (org.apache.catalina.Realm)10 ServletException (javax.servlet.ServletException)9 ArrayList (java.util.ArrayList)7 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)5 MalformedObjectNameException (javax.management.MalformedObjectNameException)5 Context (org.apache.catalina.Context)5 Loader (org.apache.catalina.Loader)5 StandardManager (org.apache.catalina.session.StandardManager)5 BindException (java.net.BindException)4 Properties (java.util.Properties)4 Lock (java.util.concurrent.locks.Lock)4 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)4 Notification (javax.management.Notification)4