Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50027
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Oct 2010 21:46:05 +0000 (21:46 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Oct 2010 21:46:05 +0000 (21:46 +0000)
Avoid NPE on start when a Context is defined in server.xml with one or more JNDI resources.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1006037 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardContext.java
webapps/docs/changelog.xml

index 1539318..e810ebf 100644 (file)
@@ -1760,9 +1760,13 @@ public class StandardContext extends ContainerBase
         support.firePropertyChange("namingResources",
                                    oldNamingResources, this.namingResources);
         
-        unregister(onameNamingResources);
-        onameNamingResources = register(namingResources,
-                "type=NamingResources," + getObjectKeyPropertiesNameOnly());
+        // If set from server.xml, getObjectKeyPropertiesNameOnly() will
+        // trigger an NPE. Initial registration takes place on INIT. 
+        if (getState() != LifecycleState.NEW) {
+            unregister(onameNamingResources);
+            onameNamingResources = register(namingResources,
+                    "type=NamingResources," + getObjectKeyPropertiesNameOnly());
+        }
     }
 
 
index 4ea9ca2..9175867 100644 (file)
         sebb. (markt)
       </update>
       <fix>
+        <bug>50027</bug>: Avoid NPE on start when a Context is defined in
+        server.xml with one or more JNDI resources. (markt)
+      </fix>
+      <fix>
         <bug>50059</bug>: JARs should always be searched for static resources
         even if the web application is marked as meta-data complete. (markt)
       </fix>