You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Remy Maucherat <re...@apache.org> on 2001/06/14 04:06:36 UTC

[T4] Lifecycle problem

Hi,

I'm fighting a lifecycle problem at the moment.
When stopping and then restarting the examples, I get :

001-06-13 18:52:00 ContextConfig[/examples] Configuration error in default
web.xml
java.lang.IllegalArgumentException: addChild:  Child name 'default' is not
unique
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
 at
org.apache.catalina.core.StandardContext.addChild(StandardContext.java:1195)
 at java.lang.reflect.Method.invoke(Native Method)
 at org.apache.catalina.util.xml.AddChild.end(XmlMapper.java:806)
[...]
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:108)
 at org.apache.catalina.util.xml.XmlMapper.readXml(XmlMapper.java:275)
 at
org.apache.catalina.startup.ContextConfig.defaultConfig(ContextConfig.java:7
27)
 at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:818)
 at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:
216)
 at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
t.java:155)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)
 at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3173)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:757)
 at
org.apache.catalina.servlets.HTMLManagerServlet.start(HTMLManagerServlet.jav
a:375)
 at
org.apache.catalina.servlets.HTMLManagerServlet.doGet(HTMLManagerServlet.jav
a:137)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[...]

The context config kicks in, and starts trying to add child wrappers which
are already there.
There's also the problem that the web.xml file could have modified, and the
context may contain stale info (like security constraints, ...).

I think we have to recycle the context object to solve this ... The
context's stop() method could be the right place to do it. Or we could also
do it in the ContextConfig (which listens to the events).

Remy


Re: [T4] More mapping problems

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 14 Jun 2001, Remy Maucherat wrote:

> Hi Craig,
> 
> (putting on my Catalina user hat)
> 
> I found a case where I think adding the default configuration mapping is done 
> wrong.
> 
> For example, you can choose to map a servlet to /*, in which case you would 
> expect it to handle all requests. That's not what happens because the default 
> config will add a mapping of the default servlet on "/".
> 
> The mapper will then send a request on "/" to the default servlet, and every 
> other URL to the other servlet.
> 
> In addition to just checking if the mappings are indentical, I think we should 
> check inclusion too (here, / is included in /*).
> 

If you have a mapping for "/*" defined, the default servlet should never
receive *any* requests.  If it does, the mapper implementation is
broken.  Note that it doesn't make any difference whether the loading was
done from the default web.xml or the application one.

A <servlet-mapping> of "/" does not literally mean mapping to the
"/" path.  Instead, it is simply a marker that says this is the default
servlet.

> (back to the developer hat)
> 
> Is it ok if I implement this behavior ?
> 

Please go ahead and fix the mapping if it's doing "/" paths wrong.

> Remy
> 

Craig



[T4] More mapping problems

Posted by Remy Maucherat <re...@betaversion.org>.
Hi Craig,

(putting on my Catalina user hat)

I found a case where I think adding the default configuration mapping is done 
wrong.

For example, you can choose to map a servlet to /*, in which case you would 
expect it to handle all requests. That's not what happens because the default 
config will add a mapping of the default servlet on "/".

The mapper will then send a request on "/" to the default servlet, and every 
other URL to the other servlet.

In addition to just checking if the mappings are indentical, I think we should 
check inclusion too (here, / is included in /*).

(back to the developer hat)

Is it ok if I implement this behavior ?

Remy

Re: [T4] Lifecycle problem

Posted by Remy Maucherat <re...@apache.org>.
> On Wed, 13 Jun 2001, Remy Maucherat wrote:
> 
> Can we accomplish this by erasing all the defined servlets, servlet
> mappings, MIME mappings, security constraints, and so on?  Recycling the
> Context object would mean we're impacting the surrounding environment
> (i.e. the Host objects that contain those Contexts) as well.

I don't see why we couldn't do that, and it appears to be enough here.
I think it would be cleaner to put that code in ContextConfig.stop().

Remy


Re: [T4] Lifecycle problem

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 13 Jun 2001, Remy Maucherat wrote:

> Hi,
> 
> I'm fighting a lifecycle problem at the moment.
> When stopping and then restarting the examples, I get :
> 
> 001-06-13 18:52:00 ContextConfig[/examples] Configuration error in default
> web.xml
> java.lang.IllegalArgumentException: addChild:  Child name 'default' is not
> unique
>  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
>  at
> org.apache.catalina.core.StandardContext.addChild(StandardContext.java:1195)
>  at java.lang.reflect.Method.invoke(Native Method)
>  at org.apache.catalina.util.xml.AddChild.end(XmlMapper.java:806)
> [...]
>  at javax.xml.parsers.SAXParser.parse(SAXParser.java:108)
>  at org.apache.catalina.util.xml.XmlMapper.readXml(XmlMapper.java:275)
>  at
> org.apache.catalina.startup.ContextConfig.defaultConfig(ContextConfig.java:7
> 27)
>  at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:818)
>  at
> org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:
> 216)
>  at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
> t.java:155)
>  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)
>  at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:3173)
>  at org.apache.catalina.core.StandardHost.start(StandardHost.java:757)
>  at
> org.apache.catalina.servlets.HTMLManagerServlet.start(HTMLManagerServlet.jav
> a:375)
>  at
> org.apache.catalina.servlets.HTMLManagerServlet.doGet(HTMLManagerServlet.jav
> a:137)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> [...]
> 
> The context config kicks in, and starts trying to add child wrappers which
> are already there.
> There's also the problem that the web.xml file could have modified, and the
> context may contain stale info (like security constraints, ...).
> 
> I think we have to recycle the context object to solve this ... The
> context's stop() method could be the right place to do it. Or we could also
> do it in the ContextConfig (which listens to the events).
> 

Can we accomplish this by erasing all the defined servlets, servlet
mappings, MIME mappings, security constraints, and so on?  Recycling the
Context object would mean we're impacting the surrounding environment
(i.e. the Host objects that contain those Contexts) as well.

> Remy
> 
> 

Craig