use of org.apache.catalina.LifecycleException in project tomcat by apache.
the class CombinedRealm method startInternal.
/**
* Prepare for the beginning of active use of the public methods of this
* component and implement the requirements of
* {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected void startInternal() throws LifecycleException {
// Start 'sub-realms' then this one
Iterator<Realm> iter = realms.iterator();
while (iter.hasNext()) {
Realm realm = iter.next();
if (realm instanceof Lifecycle) {
try {
((Lifecycle) realm).start();
} catch (LifecycleException e) {
// If realm doesn't start can't authenticate against it
iter.remove();
log.error(sm.getString("combinedRealm.realmStartFail", realm.getClass().getName()), e);
}
}
}
super.startInternal();
}
use of org.apache.catalina.LifecycleException in project tomcat by apache.
the class SetParentClassLoaderRule method stop.
/**
* Stop an existing server instance.
*/
public void stop() {
try {
// doesn't get invoked twice
if (useShutdownHook) {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
// If JULI is being used, re-enable JULI's shutdown to ensure
// log messages are not lost
LogManager logManager = LogManager.getLogManager();
if (logManager instanceof ClassLoaderLogManager) {
((ClassLoaderLogManager) logManager).setUseShutdownHook(true);
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
// This will fail on JDK 1.2. Ignoring, as Tomcat can run
// fine without the shutdown hook.
}
// Shut down the server
try {
Server s = getServer();
LifecycleState state = s.getState();
if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0 && LifecycleState.DESTROYED.compareTo(state) >= 0) {
// Nothing to do. stop() was already called
} else {
s.stop();
s.destroy();
}
} catch (LifecycleException e) {
log.error("Catalina.stop", e);
}
}
use of org.apache.catalina.LifecycleException in project tomcat by apache.
the class WebappLoader method startInternal.
/**
* Start associated {@link ClassLoader} and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected void startInternal() throws LifecycleException {
if (log.isDebugEnabled())
log.debug(sm.getString("webappLoader.starting"));
if (context.getResources() == null) {
log.info("No resources for " + context);
setState(LifecycleState.STARTING);
return;
}
// Construct a class loader based on our current repositories list
try {
classLoader = createClassLoader();
classLoader.setResources(context.getResources());
classLoader.setDelegate(this.delegate);
// Configure our repositories
setClassPath();
setPermissions();
((Lifecycle) classLoader).start();
String contextName = context.getName();
if (!contextName.startsWith("/")) {
contextName = "/" + contextName;
}
ObjectName cloname = new ObjectName(context.getDomain() + ":type=" + classLoader.getClass().getSimpleName() + ",host=" + context.getParent().getName() + ",context=" + contextName);
Registry.getRegistry(null, null).registerComponent(classLoader, cloname, null);
} catch (Throwable t) {
t = ExceptionUtils.unwrapInvocationTargetException(t);
ExceptionUtils.handleThrowable(t);
log.error("LifecycleException ", t);
throw new LifecycleException("start: ", t);
}
setState(LifecycleState.STARTING);
}
use of org.apache.catalina.LifecycleException in project spring-boot by spring-projects.
the class TomcatWebServer method stop.
@Override
public void stop() throws WebServerException {
synchronized (this.monitor) {
boolean wasStarted = this.started;
try {
this.started = false;
try {
stopTomcat();
this.tomcat.destroy();
} catch (LifecycleException ex) {
// swallow and continue
}
} catch (Exception ex) {
throw new WebServerException("Unable to stop embedded Tomcat", ex);
} finally {
if (wasStarted) {
containerCounter.decrementAndGet();
}
}
}
}
use of org.apache.catalina.LifecycleException in project sonarqube by SonarSource.
the class EmbeddedTomcat method start.
void start() {
// '%2F' (slash /) and '%5C' (backslash \) are permitted as path delimiters in URLs
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
System.setProperty("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE", "true");
tomcat = new Tomcat();
// Initialize directories
String basedir = tomcatBasedir().getAbsolutePath();
tomcat.setBaseDir(basedir);
tomcat.getHost().setAppBase(basedir);
tomcat.getHost().setAutoDeploy(false);
tomcat.getHost().setCreateDirs(false);
tomcat.getHost().setDeployOnStartup(true);
new TomcatAccessLog().configure(tomcat, props);
TomcatConnectors.configure(tomcat, props);
webappContext = new TomcatContexts().configure(tomcat, props);
try {
tomcat.start();
new TomcatStartupLogs(Loggers.get(getClass())).log(tomcat);
} catch (LifecycleException e) {
Throwables.propagate(e);
}
}
Aggregations