You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Glenn Nielsen <gl...@voyager.apg.more.net> on 2001/02/26 05:05:08 UTC

New Tomcat 4 DefaultContext server.xml element

I just committed the changes to implement a DefaultContext element
which can be nested within an Engine or Host config.  This was 
something I really needed to simplify the amount of work it takes 
to maintain a Tomcat 4 server.xml config when supporting multiple 
virtual hosts.  The biggest reason was the need to configure a
default JNDI JDBC DataSource for any web applications deployed within
a virtual host.

It seems to be working.  Let me know if you see any problems with how
I implemented this.

Regards,

Glenn

Glenn Nielsen wrote:
> 
> "Craig R. McClanahan" wrote:
> >
> > Glenn Nielsen wrote:
> >
> > > >From looking at the source it appears that a Context Lifecycle Listener
> > > can only be configured for a web app Context explicitely in server.xml.
> > > This doesn't work well when a context is automatically deployed without
> > > being configured in server.xml.  Would it be possible to add the ability
> > > to configure a default web app context Listener at the Engine and Host
> > > level that is triggered for all web app contexts if configured at the
> > > Engine scope, or for all web app contexts for a host if configured at
> > > the Host scope?
> > >
> >
> > A generalization of this concept might be a "default" configuration for an
> > automatically deployed Context within a particular Host or Engine, so that
> > you could customize things besides context listeners.
> >
> > This would be especially valuable if you utilize the automatic "User Web
> > Applications" support so that URLs like:
> >
> >     http://localhost:8080/~craigmcc/
> >
> > resolve to my public_html directory.  See the "Special Features" section of
> > the following page from the Catalina configuration docs for more info:
> >
> > http://jakarta.apache.org/tomcat/jakarta-tomcat-4.0/catalina/docs/config/host.html
> >
> > Does it make sense to think a little more broadly here?
> >
> 
> I totally agree.  Being able to setup a default configuration for Hosts or
> Webapps
> would be very valuable.  Inheritance would also be nice.  This might also work
> to solve the issue I raised earlier about configuring JNDI resources at the
> Engine or Host level that get inherited by a web app context.
> 
> The virtual host support for configuring multiple hosts, app base location,
> and logging is great.  But what has been lacking is the above mechanism
> for setting default configurations.  This is especially important if
> you are deploying Tomcat 4 for dozens, perhaps 100's of virtual hosts.
> Managing the server.xml config would quickly become a huge headache unless
> you had a way to setup defaults for a context including things like JNDI
> resources and data sources.
> 
> I really need the above feature and am willing to help make it happen.
> 
> Regards,
> 
> Glenn
> 
> ----------------------------------------------------------------------
> Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
> MOREnet System Programming               |  * if iz ina coment.      |
> Missouri Research and Education Network  |  */                       |
> ----------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org

-- 
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: New Tomcat 4 DefaultContext server.xml element

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
"Craig R. McClanahan" wrote:
> 
> Remy Maucherat wrote:
> 
> > > Glenn Nielsen wrote:
> > > On both Linux and Win98, I get an NPE at startup time:
> > >
> > > Starting service Tomcat-Standalone
> > > Apache Tomcat/4.0-dev
> > > java.lang.NullPointerException
> > >         at
> > org.apache.catalina.core.StandardEngine.importDefaultContext(Standard
> > > Engine.java:195)
> > >         at
> > org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:78
> > > 7)
> > >         at
> > org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
> > > g.java:211)
> > >         at
> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
> > > eSupport.java, Compiled Code)
> > >         at
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> > > iled Code)
> > >         at
> > org.apache.catalina.core.StandardContext.start(StandardContext.java:2
> > > 990)
> > >         at
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> > > iled Code)
> > >         at
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> > > iled Code)
> > >         at
> > org.apache.catalina.core.StandardEngine.start(StandardEngine.java:253
> > > )
> > >         at
> > org.apache.catalina.core.StandardService.start(StandardService.java:3
> > > 53)
> > >         at
> > org.apache.catalina.core.StandardServer.start(StandardServer.java:454
> > > )
> > >         at org.apache.catalina.startup.Catalina.start(Catalina.java:707)
> > >         at org.apache.catalina.startup.Catalina.execute(Catalina.java:627)
> > >         at org.apache.catalina.startup.Catalina.process(Catalina.java:177)
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:177)
> >
> > There is an extra ';' at the end of an if statement. Who commits the fix ?
> >
> 
> Since you found it, be my guest :-)
> 
> >
> > Remy
> >
> 
> Craig
> 

Looks like Remy fixed it, thanks!  Must of been that darn cat that ran
across my keyboard.  Wait a minute, I don't have a cat.  In fact, I
_hate_ cats!


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

-- 
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: New Tomcat 4 DefaultContext server.xml element

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Remy Maucherat wrote:

> > Glenn Nielsen wrote:
> > On both Linux and Win98, I get an NPE at startup time:
> >
> > Starting service Tomcat-Standalone
> > Apache Tomcat/4.0-dev
> > java.lang.NullPointerException
> >         at
> org.apache.catalina.core.StandardEngine.importDefaultContext(Standard
> > Engine.java:195)
> >         at
> org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:78
> > 7)
> >         at
> org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
> > g.java:211)
> >         at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
> > eSupport.java, Compiled Code)
> >         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> > iled Code)
> >         at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:2
> > 990)
> >         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> > iled Code)
> >         at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> > iled Code)
> >         at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:253
> > )
> >         at
> org.apache.catalina.core.StandardService.start(StandardService.java:3
> > 53)
> >         at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:454
> > )
> >         at org.apache.catalina.startup.Catalina.start(Catalina.java:707)
> >         at org.apache.catalina.startup.Catalina.execute(Catalina.java:627)
> >         at org.apache.catalina.startup.Catalina.process(Catalina.java:177)
> >         at java.lang.reflect.Method.invoke(Native Method)
> >         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:177)
>
> There is an extra ';' at the end of an if statement. Who commits the fix ?
>

Since you found it, be my guest :-)

>
> Remy
>

Craig



Re: New Tomcat 4 DefaultContext server.xml element

Posted by Remy Maucherat <re...@apache.org>.
> Glenn Nielsen wrote:
> On both Linux and Win98, I get an NPE at startup time:
>
> Starting service Tomcat-Standalone
> Apache Tomcat/4.0-dev
> java.lang.NullPointerException
>         at
org.apache.catalina.core.StandardEngine.importDefaultContext(Standard
> Engine.java:195)
>         at
org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:78
> 7)
>         at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
> g.java:211)
>         at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
> eSupport.java, Compiled Code)
>         at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> iled Code)
>         at
org.apache.catalina.core.StandardContext.start(StandardContext.java:2
> 990)
>         at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> iled Code)
>         at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
> iled Code)
>         at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:253
> )
>         at
org.apache.catalina.core.StandardService.start(StandardService.java:3
> 53)
>         at
org.apache.catalina.core.StandardServer.start(StandardServer.java:454
> )
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:707)
>         at org.apache.catalina.startup.Catalina.execute(Catalina.java:627)
>         at org.apache.catalina.startup.Catalina.process(Catalina.java:177)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:177)

There is an extra ';' at the end of an if statement. Who commits the fix ?

Remy


Re: New Tomcat 4 DefaultContext server.xml element

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Glenn Nielsen wrote:

> I just committed the changes to implement a DefaultContext element
> which can be nested within an Engine or Host config.  This was
> something I really needed to simplify the amount of work it takes
> to maintain a Tomcat 4 server.xml config when supporting multiple
> virtual hosts.  The biggest reason was the need to configure a
> default JNDI JDBC DataSource for any web applications deployed within
> a virtual host.
>
> It seems to be working.  Let me know if you see any problems with how
> I implemented this.
>

On both Linux and Win98, I get an NPE at startup time:

Starting service Tomcat-Standalone
Apache Tomcat/4.0-dev
java.lang.NullPointerException
        at org.apache.catalina.core.StandardEngine.importDefaultContext(Standard
Engine.java:195)
        at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:78
7)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
g.java:211)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java, Compiled Code)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
iled Code)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:2
990)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
iled Code)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java, Comp
iled Code)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:253
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:3
53)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:454
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:707)
        at org.apache.catalina.startup.Catalina.execute(Catalina.java:627)
        at org.apache.catalina.startup.Catalina.process(Catalina.java:177)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:177)


> Regards,
>
> Glenn
>

Craig



Re: New Tomcat 4 DefaultContext server.xml element

Posted by Remy Maucherat <re...@apache.org>.
> I just committed the changes to implement a DefaultContext element
> which can be nested within an Engine or Host config.  This was
> something I really needed to simplify the amount of work it takes
> to maintain a Tomcat 4 server.xml config when supporting multiple
> virtual hosts.  The biggest reason was the need to configure a
> default JNDI JDBC DataSource for any web applications deployed within
> a virtual host.
>
> It seems to be working.  Let me know if you see any problems with how
> I implemented this.

That looks good. I had a look at the implementation, which is rather
straightforward, so hopefully it won't break. I indeed looks like the right
way to implement the shared JNDI resources you were talking about.

Remy