You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2005/01/16 19:06:28 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

Posted by Remy Maucherat <re...@apache.org>.
Mark Thomas wrote:
> Do you mean risky in general or risky in TC5? I understand why it would 
> be in TC5 but not in the general case.

I meant that the patch touches a sensitive area, which makes it risky. I 
didn't really read it (I don't use 4.1 anymore), so it will likely be 
fine :)

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

Posted by Mark Thomas <ma...@apache.org>.
Remy Maucherat wrote:
> markt@apache.org wrote:
> 
>> 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.
> 
> 
> Please don't try porting this fix (which is very risky) as I would have 
> to veto it. Service name, engine name, and JMX domain are all tied in TC 5.

Do you mean risky in general or risky in TC5? I understand why it would 
be in TC5 but not in the general case.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

Posted by Remy Maucherat <re...@apache.org>.
markt@apache.org wrote:
> 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.

Please don't try porting this fix (which is very risky) as I would have 
to veto it. Service name, engine name, and JMX domain are all tied in TC 5.

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message ----- 
From: "Remy Maucherat" <re...@apache.org>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Sunday, January 16, 2005 10:38 AM
Subject: Re: cvs commit: 
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core 
StandardContext.java


>Mark Thomas wrote:
>> FWIW I also did some testing around this on TC5. Multiple services that 
>> each contain an engine with the same name creates all sorts of confusion. 
>> It behaves as if the same engine is shared by multiple services but I 
>> haven't looked at the code yet so I am not 100% sure what is actually 
>> going on.
>>
>> Until I figure out what is going on the work-around (for those few users 
>> who might have this setup) is simple - use different names for the each 
>> engine.
>
>Yes, there's still redundant data in this area (name on both the engine and 
>service), and not enough checks are done. Engine names must be unique, and 
>should match the associated service name (as at the end, it ends up being 
>used as the JMX domain).
>
>One cleanup area I missed in 5.5 development. I suppose there was far more 
>urgent cleanup to do, and we can now focus on details that were overlooked 
>:)
>(but after Yoav tags 5.5.7, thx ;) )
>

Yes, merging the Engine and the Service would have been a nice cleanup for 
5.5, but wasn't as urgent as the other stuff.  For example, from the JMX 
OName point of view, it looks like it should be possible to have multiple 
Services attached to the same Engine (but you certainly can't have multiple 
Engines with the same Service).

Given that 5.5 has had a stable release, it's probably not a good idea to do 
this in that branch.  Possibly something for the TC 6 release plan.

>Rémy
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org




This message is intended only for the use of the person(s) listed above as the intended recipient(s), and may contain information that is PRIVILEGED and CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or distribute this message or any attachment. If you received this communication in error, please notify us immediately by e-mail and then delete all copies of this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through the Internet is not secure. Do not send confidential or sensitive information, such as social security numbers, account numbers, personal identification numbers and passwords, to us via ordinary (unencrypted) e-mail.



Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

Posted by Remy Maucherat <re...@apache.org>.
Mark Thomas wrote:
> FWIW I also did some testing around this on TC5. Multiple services that 
> each contain an engine with the same name creates all sorts of 
> confusion. It behaves as if the same engine is shared by multiple 
> services but I haven't looked at the code yet so I am not 100% sure what 
> is actually going on.
> 
> Until I figure out what is going on the work-around (for those few users 
> who might have this setup) is simple - use different names for the each 
> engine.

Yes, there's still redundant data in this area (name on both the engine 
and service), and not enough checks are done. Engine names must be 
unique, and should match the associated service name (as at the end, it 
ends up being used as the JMX domain).

One cleanup area I missed in 5.5 development. I suppose there was far 
more urgent cleanup to do, and we can now focus on details that were 
overlooked :)
(but after Yoav tags 5.5.7, thx ;) )

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core StandardContext.java

Posted by Mark Thomas <ma...@apache.org>.
FWIW I also did some testing around this on TC5. Multiple services that 
each contain an engine with the same name creates all sorts of 
confusion. It behaves as if the same engine is shared by multiple 
services but I haven't looked at the code yet so I am not 100% sure what 
is actually going on.

Until I figure out what is going on the work-around (for those few users 
who might have this setup) is simple - use different names for the each 
engine.

Mark

markt@apache.org wrote:
> 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: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org