Author: markt Date: Thu Feb 24 17:03:27 2011 New Revision: 1074215 URL: http://svn.apache.org/viewvc?rev=1074215&view=rev Log: Don't start NamingResources multiple times
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1074215&r1=1074214&r2=1074215&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Thu Feb 24 17:03:27 2011 @@ -1952,24 +1952,36 @@ public class StandardContext extends Con support.firePropertyChange("namingResources", oldNamingResources, this.namingResources); - // If set from server.xml, getObjectKeyPropertiesNameOnly() will - // trigger an NPE. Initial registration takes place on INIT. - if (getState() != LifecycleState.NEW) { - if (oldNamingResources != null) { - try { - oldNamingResources.stop(); - oldNamingResources.destroy(); - } catch (LifecycleException e) { - log.warn("standardContext.namingResource.destroy.fail", e); - } + if (getState() == LifecycleState.NEW || + getState() == LifecycleState.INITIALIZING || + getState() == LifecycleState.INITIALIZED) { + // NEW will occur if Context is defined in server.xml + // At this point getObjectKeyPropertiesNameOnly() will trigger an + // NPE. + // INITIALIZED will occur if the Context is defined in a context.xml + // file + // If started now, a second start will be attempted when the context + // starts + + // In both cases, return and let context init the namingResources + // when it starts + return; + } + + if (oldNamingResources != null) { + try { + oldNamingResources.stop(); + oldNamingResources.destroy(); + } catch (LifecycleException e) { + log.warn("standardContext.namingResource.destroy.fail", e); } - if (namingResources != null) { - try { - namingResources.init(); - namingResources.start(); - } catch (LifecycleException e) { - log.warn("standardContext.namingResource.init.fail", e); - } + } + if (namingResources != null) { + try { + namingResources.init(); + namingResources.start(); + } catch (LifecycleException e) { + log.warn("standardContext.namingResource.init.fail", e); } } } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1074215&r1=1074214&r2=1074215&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Feb 24 17:03:27 2011 @@ -138,6 +138,10 @@ of whether or not they provide a session token with their requests. (markt) </add> + <fix> + Don't attempt to start NamingResources for Contexts multiple times. + (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org