use of org.apache.catalina.LifecycleException in project tomcat70 by apache.
the class LifecycleBase method init.
@Override
public final synchronized void init() throws LifecycleException {
if (!state.equals(LifecycleState.NEW)) {
invalidTransition(Lifecycle.BEFORE_INIT_EVENT);
}
try {
setStateInternal(LifecycleState.INITIALIZING, null, false);
initInternal();
setStateInternal(LifecycleState.INITIALIZED, null, false);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
setStateInternal(LifecycleState.FAILED, null, false);
throw new LifecycleException(sm.getString("lifecycleBase.initFail", toString()), t);
}
}
use of org.apache.catalina.LifecycleException in project fess by codelibs.
the class FessWebResourceRoot method processWebInfLib.
@Override
protected void processWebInfLib() throws LifecycleException {
super.processWebInfLib();
final WebResource[] possibleJars = listResources("/WEB-INF/plugin", false);
for (final WebResource possibleJar : possibleJars) {
if (possibleJar.isFile() && possibleJar.getName().endsWith(".jar")) {
try (final JarFile jarFile = new JarFile(possibleJar.getCanonicalPath())) {
final Manifest manifest = jarFile.getManifest();
if (manifest != null && manifest.getEntries() != null) {
final Attributes attributes = manifest.getMainAttributes();
if (attributes != null && (attributes.get("Fess-WebAppJar") != null || attributes.getValue("Fess-WebAppJar") != null)) {
createWebResourceSet(ResourceSetType.CLASSES_JAR, "/WEB-INF/classes", possibleJar.getURL(), "/");
}
}
} catch (final Exception e) {
logger.log(Level.WARNING, "Failed to read " + possibleJar, e);
}
}
}
}
use of org.apache.catalina.LifecycleException in project tomee by apache.
the class TomcatWebAppBuilder method addTomEERealm.
private void addTomEERealm(final Engine engine) {
final Realm realm = engine.getRealm();
if (realm != null && !(realm instanceof TomEERealm) && (engine.getParent() == null || (!realm.equals(engine.getParent().getRealm())))) {
final Realm tomeeRealm = tomeeRealm(realm);
engine.setRealm(tomeeRealm);
if (LifecycleState.STARTING_PREP.equals(engine.getState())) {
try {
Lifecycle.class.cast(tomeeRealm).start();
} catch (final LifecycleException e) {
throw new IllegalStateException(e);
}
}
}
}
use of org.apache.catalina.LifecycleException in project tomee by apache.
the class LazyValve method instance.
private Valve instance() {
if (delegate == null) {
synchronized (this) {
if (delegate == null) {
final Object instance;
ClassLoader cl = loader();
if (cl == null) {
return null;
}
final Class<?> clazz;
try {
clazz = cl.loadClass(delegateClassName);
} catch (final ClassNotFoundException e) {
throw new TomEERuntimeException(e);
}
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);
}
delegate = Valve.class.cast(instance);
delegate.setNext(next);
if (Contained.class.isInstance(delegate)) {
Contained.class.cast(delegate).setContainer(container);
}
if (Lifecycle.class.isInstance(delegate)) {
if (init) {
try {
final Lifecycle lifecycle = Lifecycle.class.cast(delegate);
for (final LifecycleListener listener : lifecycleListeners) {
lifecycle.addLifecycleListener(listener);
}
lifecycle.init();
if (start) {
lifecycle.start();
}
} catch (final LifecycleException e) {
// no-op
}
}
}
if (ClusterValve.class.isInstance(delegate)) {
ClusterValve.class.cast(delegate).setCluster(cluster);
}
}
}
}
return delegate;
}
use of org.apache.catalina.LifecycleException in project tomee by apache.
the class TomcatWebAppBuilder method destroy.
/**
* {@inheritDoc}
*/
@Override
public void destroy(final StandardContext standardContext) {
final Loader standardContextLoader = standardContext.getLoader();
if (LazyStopLoader.class.isInstance(standardContextLoader)) {
final Loader delegate = LazyStopLoader.class.cast(standardContextLoader).getDelegateLoader();
if (TomEEWebappLoader.class.isInstance(delegate)) {
final TomEEWebappLoader webappLoader = TomEEWebappLoader.class.cast(delegate);
final ClassLoader loader = webappLoader.internalLoader();
webappLoader.clearLoader();
if (TomEEWebappClassLoader.class.isInstance(loader)) {
TomEEWebappClassLoader.class.cast(loader).internalDestroy();
}
}
}
final WebResourceRoot root = standardContext.getResources();
if (LazyStopStandardRoot.class.isInstance(root)) {
try {
LazyStopStandardRoot.class.cast(root).internalDestroy();
} catch (final LifecycleException e) {
throw new IllegalStateException(e);
}
}
}
Aggregations