markt       2005/01/16 10:06:28

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
  Log:
  Fix bug 25508. Multiple services configured with engines of the same name
  cause JNDI lookups to fail in all but the first engine to be created. Use the
  service name (which has to be unique) rather than the engine name when
  building the NamingContext name.
  
  Revision  Changes    Path
  1.128     +34 -20    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.127
  retrieving revision 1.128
  diff -u -r1.127 -r1.128
  --- StandardContext.java      24 Dec 2004 16:48:18 -0000      1.127
  +++ StandardContext.java      16 Jan 2005 18:06:28 -0000      1.128
  @@ -42,6 +42,7 @@
   import org.apache.catalina.Container;
   import org.apache.catalina.ContainerListener;
   import org.apache.catalina.Context;
  +import org.apache.catalina.Engine;
   import org.apache.catalina.Host;
   import org.apache.catalina.Globals;
   import org.apache.catalina.InstanceListener;
  @@ -53,6 +54,7 @@
   import org.apache.catalina.Mapper;
   import org.apache.catalina.Request;
   import org.apache.catalina.Response;
  +import org.apache.catalina.Service;
   import org.apache.catalina.Wrapper;
   import org.apache.catalina.deploy.ApplicationParameter;
   import org.apache.catalina.deploy.ContextEjb;
  @@ -3943,25 +3945,37 @@
        * Get naming context full name.
        */
       private String getNamingContextName() {
  -     if (namingContextName == null) {
  -         Container parent = getParent();
  -         if (parent == null) {
  -             namingContextName = getName();
  -         } else {
  -             Stack stk = new Stack();
  -             StringBuffer buff = new StringBuffer();
  -             while (parent != null) {
  -                 stk.push(parent.getName());
  -                 parent = parent.getParent();
  -             }
  -             while (!stk.empty()) {
  -                 buff.append("/" + stk.pop());
  -             }
  -             buff.append(getName());
  -             namingContextName = buff.toString();
  -         }
  -     }
  -     return namingContextName;
  +        if (namingContextName == null) {
  +            Container parent = getParent();
  +            if (parent == null) {
  +                namingContextName = getName();
  +            } else {
  +                Stack stk = new Stack();
  +                StringBuffer buff = new StringBuffer();
  +                while (parent != null) {
  +                    // Use service name rather than engine name to guarantee
  +                    // uniqueness - fixes bug 25508
  +                    if (parent instanceof Engine) {
  +                        Service service = ((Engine) parent).getService(); 
  +                        if (service == null) {
  +                            // use engine name anyway
  +                            stk.push(parent.getName());
  +                        } else {
  +                            stk.push(service.getName());
  +                        }
  +                    } else {
  +                        stk.push(parent.getName());
  +                    }
  +                    parent = parent.getParent();
  +                }
  +                while (!stk.empty()) {
  +                    buff.append("/" + stk.pop());
  +                }
  +                buff.append(getName());
  +                namingContextName = buff.toString();
  +            }
  +        }
  +        return namingContextName;
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to