Justin,
I followed your advice immediately, but the exact same thing happens.
My response was tongue-in-cheek, but that's ok. :)
Just to restate the issue, my servlet hangs because it needs to obtain an
XML Schema from localhost:8080. But it can't get it, because Tomcat won't
finish loading until the servlet is finished. But the servlet won't finish
until Tomcat finishes loading. Etcetera, etcetera ad infinitum.
I've got some sort of logic issue here. If I want to kick off a program
that polls a directory for XML files, should I probably do something where I
kick off an independent thread, so that Tomcat is not waiting for my program
to finish (which if it's a good poller, it never will)?
Ah, I see. Using the ServletContextListener will make your life easier going forward, but it doesn't directly address what you're talking about here. As others have said, you may be able to solve the immediate problem with an EntityResolver (pretty standard). The larger question, though, remains.
Since there's no standard way to make a webApp unavailable after it has been fully initialized, whatever resources you need to verify the startup have to be available during the contextInitialized() timeframe. That means your options for deployment are a tad limited (ie where to place these schemas), regardless of whether you use an EntityResolver or not. It's really an issue of what types of restrictions you're willing to place on the deployment ... if it's always deployed as an exploded dir, you could use a init param to specify the OS filesystem location of the schema (or an EntityResolver). If you can put the schema somewhere in the webapp or container's classpath, you can use the getResourceAsStream() method.
If you truly need to poll indefinitely for XML files (files will change during runtime), but reading one of them isn't required for you to start the context successfully, then you could fire off the thread and let your startup finish gracefully.
Just depends on the other conditions of your app.
justin
-----Original Message----- From: Adrian Klingel [mailto:[EMAIL PROTECTED] Sent: Friday, April 23, 2004 6:52 PM To: Adrian Klingel - Exaweb Subject: FW: Tomcat stops loading when I run my servlet with <load-on-startup>
-----Original Message----- From: Justin Ruthenbeck [mailto:[EMAIL PROTECTED] Sent: Friday, April 23, 2004 6:47 PM To: Tomcat Users List Subject: Re: Tomcat stops loading when I run my servlet with <load-on-startup>
Yes. Rip out the load-on-startup. Now. Don't wait till Monday. Replace with a context listener (see: javax.servlet.ServletContextListener). Relax and have a stress-free weekend.
justin
At 01:55 PM 4/23/2004, you wrote:
>Look at listeners. I think there was a similar thread a while back and the
>solution was to have a listener kick off the servlet after all the other
>processes were done. You could also have your servlet start and then wait
>for a certain amount of time, to allow time for all other processes to
>start.
>
>Doug
>
>
>----- Original Message -----
>From: "Adrian Klingel" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, April 23, 2004 4:03 PM
>Subject: Tomcat stops loading when I run my servlet with <load-on-startup>
>
>
> > I have a servlet which calls a method on itself to poll a directory for
>XML
> > files. When one is found, another method ("read()" is called which
> then
> > creates a SAX parser and attempts to validate the file against an XML
> > schema. Upon calling the "parse()" method, Tomcat freezes. It doesn't
> > create or write to a log, and nothing else starts up. Nothing is
>accessible
> > on port 8080, because Tomcat doesn't make it to the point where it
> mounts
> > that port.
> >
> > When I remove the <load-on-startup> from this particular app's web.xml,
> > Tomcat completes its startup process and things are accessible. I can
>then
> > reintroduce the <load-on-startup> to the web.xml and Tomcat will
> > automatically kick off the servlet. This time nothing freezes, and the
> > program runs as it is supposed to.
> >
> > My program is attempting to validate this XML file against a schema
> which
>is
> > accessible locally on port 8080. But that port is prevented from
> becoming
> > available, so the program will just wait forever.
> >
> > My question is, how can I prevent my servlet from starting up until
> after
> > Tomcat has completed its startup procedure? I've specified higher
> numbers
> > in the <load-on-startup> element, but to no avail.
> >
> > Thanks for any help you can offer.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
______________________________________________ Justin Ruthenbeck Software Engineer, NextEngine Inc. justinr - AT - nextengine DOT com Confidential. See: http://www.nextengine.com/confidentiality.php ______________________________________________
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
______________________________________________ Justin Ruthenbeck Software Engineer, NextEngine Inc. justinr - AT - nextengine DOT com Confidential. See: http://www.nextengine.com/confidentiality.php ______________________________________________
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
