I've seen some issues similar to those. Sometimes (I could not establish 
the pattern for now), this is what appears in TC 3.3 logs:

-------------------------------------------
2001-10-29 16:35:51 - ContextManager: Removing context www.dev.dev:/ROOT
2001-10-29 16:35:51 - Ctx() : Remove mapping
2001-10-29 16:35:51 - Ctx() : Remove mapping /login/j_security_check
2001-10-29 16:35:51 - ContextManager: Adding context www.dev.dev:/ROOT
2001-10-29 16:36:03 - JDBCRealm: The database connection is null or was 
found to
  be closed. Trying to re-open it.
2001-10-29 16:41:37 - ContextManager: Removing context www.dev.dev:/ROOT
2001-10-29 16:41:37 - Ctx() : Remove mapping
2001-10-29 16:41:37 - Ctx() : Remove mapping /login/j_security_check
2001-10-29 16:41:37 - ContextManager: Adding context www.dev.dev:/ROOT
2001-10-29 16:41:37 - Ctx() : Validating web.xml

2001-10-29 16:41:37 - Ctx() : web.xml: Error 
org.xml.sax.SAXParseException: Element "web-app" does not allow 
"session-config" here.
-------------------------------------------

Notice that here, only the second time around things go bad (at context 
reload) and that's only sometimes. Normally, there is nothing in the 
logs. Weird...

I'll have to dig into it to find out what it really is. I might apply 
this patch to my local build, just to see if it makes any difference.

Bojan

Schreibman, David wrote:

> Hi All,
> 
> Some people I work with noticed that Tomcat was spitting out a web.xml
> validation error for their app, but only the first time they started up.
> This gave them the impression that everything was ok the second time.
> 
> Well, I looked around a bit and found that WebXmlReader writes out a
> "validation mark" (webxmlval.txt) in the work directory.  The timestamp of
> the validation mark is used as part of deciding whether to validate.  The
> thing is, this mark is written out even if web.xml was not valid so next
> time through validation is skipped.
> 
> I'm not sure if this was done on purpose and I can even imagine an argument
> about not nagging more than once.  Still, in our case the disappearance of
> the validation errors brought about false confidence.
> 
> In case this seems like a problem to anyone else, here's a patch that only
> writes out the validation mark if the XML parsed without errors.  That way
> you keep seeing the validation errors until you a) disable validation or b)
> fix the offending xml.
> 
> Interestingly, this patch takes advantage of an unused boolean field in the
> error handler.  Makes me wonder if somebody already thought of this but
> decided not to deal with it.  Perhaps there was a good reason.
> 
> Regards,
> 
> -David
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --- WebXmlReader.java.orig    Wed Oct 31 13:00:07 2001
> +++ WebXmlReader.java Wed Oct 31 12:12:55 2001
> @@ -99,7 +99,7 @@
>      static class WebXmlErrorHandler implements ErrorHandler{
>       Context ctx;
>       XmlMapper xm;
> -     boolean ok;
> +     boolean ok = true;
>       WebXmlErrorHandler( XmlMapper xm,Context ctx ) {
>           this.ctx=ctx;
>           this.xm=xm;
> @@ -113,16 +113,21 @@
>       public void error (SAXParseException exception)
>           throws SAXException
>       {
> +         ok = false;
>           ctx.log("web.xml: Error " + exception );
>           ctx.log(xm.positionToString());
>       }
>       public void fatalError (SAXParseException exception)
>           throws SAXException
>       {
> +         ok = false;
>           ctx.log("web.xml: Fatal error " + exception );
>           ctx.log(xm.positionToString());
>           throw new SAXException( "Fatal error " + exception );
>       }
> +     public boolean isOk() {
> +         return ok;
> +     }
>      }
>      
>      void processWebXmlFile( Context ctx, String file) {
> @@ -134,13 +139,15 @@
>           }
>           if( ctx.getDebug() > 0 ) ctx.log("Reading " + file );
>           XmlMapper xh=new XmlMapper();
> +         WebXmlErrorHandler xeh = null;
>           File v=new File( ctx.getWorkDir(), "webxmlval.txt" );
>           if( validate ) {
>               if( ! v.exists() || 
>                   v.lastModified() < f.lastModified() ) {
>                   ctx.log("Validating web.xml");
>                   xh.setValidating(true);
> -                 xh.setErrorHandler( new WebXmlErrorHandler( xh, ctx ) );
> +                 xeh = new WebXmlErrorHandler( xh, ctx );
> +                 xh.setErrorHandler( xeh );
>               }
>           }
>  
> @@ -230,7 +237,8 @@
>  
>           Object ctx1=xh.readXml(f, ctx);
>  
> -         if( validate ) {
> +         if( validate && xeh.isOk()) {
> +             // don't create/update the validation mark if an error was detected
>               try {
>                   FileOutputStream fos=new FileOutputStream( v );
>                   fos.write( 1 );
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 



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

Reply via email to