Search in sources :

Example 46 with LifecycleException

use of org.apache.catalina.LifecycleException in project redisson by redisson.

the class RedissonSessionManager method stopInternal.

@Override
protected void stopInternal() throws LifecycleException {
    super.stopInternal();
    setState(LifecycleState.STOPPING);
    try {
        if (redisson != null) {
            redisson.shutdown();
        }
    } catch (Exception e) {
        throw new LifecycleException(e);
    }
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException)

Example 47 with LifecycleException

use of org.apache.catalina.LifecycleException in project geode by apache.

the class Tomcat7DeltaSessionManager method startInternal.

/**
   * 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.
   *
   * @throws LifecycleException if this component detects a fatal error that prevents this component
   *         from being used
   */
@Override
public void startInternal() throws LifecycleException {
    super.startInternal();
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(this + ": Starting");
    }
    if (this.started.get()) {
        return;
    }
    this.lifecycle.fireLifecycleEvent(START_EVENT, null);
    // Register our various valves
    registerJvmRouteBinderValve();
    if (isCommitValveEnabled()) {
        registerCommitSessionValve();
    }
    // Initialize the appropriate session cache interface
    initializeSessionCache();
    try {
        load();
    } catch (ClassNotFoundException e) {
        throw new LifecycleException("Exception starting manager", e);
    } catch (IOException e) {
        throw new LifecycleException("Exception starting manager", e);
    }
    // Create the timer and schedule tasks
    scheduleTimerTasks();
    this.started.set(true);
    this.setState(LifecycleState.STARTING);
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException)

Example 48 with LifecycleException

use of org.apache.catalina.LifecycleException in project geode by apache.

the class Tomcat8DeltaSessionManager method startInternal.

/**
   * 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.
   *
   * @throws LifecycleException if this component detects a fatal error that prevents this component
   *         from being used
   */
@Override
public void startInternal() throws LifecycleException {
    super.startInternal();
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(this + ": Starting");
    }
    if (this.started.get()) {
        return;
    }
    fireLifecycleEvent(START_EVENT, null);
    // Register our various valves
    registerJvmRouteBinderValve();
    if (isCommitValveEnabled()) {
        registerCommitSessionValve();
    }
    // Initialize the appropriate session cache interface
    initializeSessionCache();
    try {
        load();
    } catch (ClassNotFoundException e) {
        throw new LifecycleException("Exception starting manager", e);
    } catch (IOException e) {
        throw new LifecycleException("Exception starting manager", e);
    }
    // Create the timer and schedule tasks
    scheduleTimerTasks();
    this.started.set(true);
    this.setState(LifecycleState.STARTING);
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException)

Example 49 with LifecycleException

use of org.apache.catalina.LifecycleException in project tomee by apache.

the class LazyRealm method instance.

private Realm instance() {
    if (delegate == null) {
        synchronized (this) {
            if (delegate == null) {
                final Object instance;
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                if (container != null && container.getLoader() != null && container.getLoader().getClassLoader() != null) {
                    cl = container.getLoader().getClassLoader();
                }
                final Class<?> clazz;
                try {
                    clazz = cl.loadClass(realmClass);
                } catch (final ClassNotFoundException e) {
                    throw new TomEERuntimeException(e);
                }
                if (!cdi) {
                    try {
                        final ObjectRecipe recipe = new ObjectRecipe(clazz);
                        recipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
                        recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
                        recipe.allow(Option.FIELD_INJECTION);
                        recipe.allow(Option.PRIVATE_PROPERTIES);
                        if (properties != null) {
                            final Properties props = new PropertiesAdapter().unmarshal(properties.trim().replaceAll("\\p{Space}*(\\p{Alnum}*)=", "\n$1="));
                            recipe.setAllProperties(props);
                        }
                        instance = recipe.create();
                    } catch (final Exception e) {
                        throw new TomEERuntimeException(e);
                    }
                } else {
                    final WebBeansContext webBeansContext;
                    try {
                        webBeansContext = WebBeansContext.currentInstance();
                        if (webBeansContext == null) {
                            return null;
                        }
                    } catch (final IllegalStateException ise) {
                        // too early to have a cdi bean, skip these methods - mainly init() but @PostConstruct works then
                        return null;
                    }
                    final BeanManager bm = webBeansContext.getBeanManagerImpl();
                    final Set<Bean<?>> beans = bm.getBeans(clazz);
                    final Bean<?> bean = bm.resolve(beans);
                    if (bean == null) {
                        return null;
                    }
                    creationalContext = bm.createCreationalContext(null);
                    instance = bm.getReference(bean, clazz, creationalContext);
                }
                if (instance == null) {
                    throw new TomEERuntimeException("realm can't be retrieved from cdi");
                }
                if (instance instanceof Realm) {
                    delegate = (Realm) instance;
                    delegate.setContainer(container);
                    delegate.setCredentialHandler(credentialHandler);
                    if (Lifecycle.class.isInstance(delegate)) {
                        if (init) {
                            try {
                                final Lifecycle lifecycle = Lifecycle.class.cast(delegate);
                                lifecycle.init();
                                if (start) {
                                    lifecycle.start();
                                }
                            } catch (final LifecycleException e) {
                            // no-op
                            }
                        }
                    }
                } else {
                    delegate = new LowTypedRealm(instance);
                    delegate.setContainer(container);
                    delegate.setCredentialHandler(credentialHandler);
                }
                for (final PropertyChangeListener listener : support.getPropertyChangeListeners()) {
                    delegate.addPropertyChangeListener(listener);
                }
            }
        }
    }
    return delegate;
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) PropertyChangeListener(java.beans.PropertyChangeListener) Lifecycle(org.apache.catalina.Lifecycle) Properties(java.util.Properties) TomEERuntimeException(org.apache.tomee.catalina.TomEERuntimeException) LifecycleException(org.apache.catalina.LifecycleException) IOException(java.io.IOException) TomEERuntimeException(org.apache.tomee.catalina.TomEERuntimeException) Bean(javax.enterprise.inject.spi.Bean) PropertiesAdapter(org.apache.openejb.config.sys.PropertiesAdapter) WebBeansContext(org.apache.webbeans.config.WebBeansContext) ObjectRecipe(org.apache.xbean.recipe.ObjectRecipe) BeanManager(javax.enterprise.inject.spi.BeanManager) Realm(org.apache.catalina.Realm)

Example 50 with LifecycleException

use of org.apache.catalina.LifecycleException in project tomee by apache.

the class Container method stop.

public void stop() throws Exception {
    final Connector connector = tomcat.getConnector();
    if (null != connector) {
        connector.stop();
    }
    try {
        tomcat.stop();
    } catch (final LifecycleException e) {
        e.printStackTrace();
    }
    try {
        tomcat.destroy();
    } catch (final LifecycleException e) {
        e.printStackTrace();
    }
    if (configuration.isDeleteBaseOnStartup()) {
        try {
            deleteTree(base);
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }
    OpenEJB.destroy();
// don't set base = null here to be able to use base after to clean up from outside of this class
}
Also used : Connector(org.apache.catalina.connector.Connector) LifecycleException(org.apache.catalina.LifecycleException) NamingException(javax.naming.NamingException) UndeployException(org.apache.openejb.UndeployException) LifecycleException(org.apache.catalina.LifecycleException) OpenEJBException(org.apache.openejb.OpenEJBException) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) TomEERuntimeException(org.apache.tomee.catalina.TomEERuntimeException)

Aggregations

LifecycleException (org.apache.catalina.LifecycleException)50 Lifecycle (org.apache.catalina.Lifecycle)16 IOException (java.io.IOException)15 Realm (org.apache.catalina.Realm)8 File (java.io.File)7 NamingException (javax.naming.NamingException)6 Container (org.apache.catalina.Container)6 InputStream (java.io.InputStream)4 Lock (java.util.concurrent.locks.Lock)4 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)4 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)4 ServletException (javax.servlet.ServletException)4 Contained (org.apache.catalina.Contained)4 Loader (org.apache.catalina.Loader)4 Valve (org.apache.catalina.Valve)4 WebappLoader (org.apache.catalina.loader.WebappLoader)4 FileInputStream (java.io.FileInputStream)3 MalformedURLException (java.net.MalformedURLException)3 ServletContext (javax.servlet.ServletContext)3 Cluster (org.apache.catalina.Cluster)3