Re: Getting the Tomcat shutdown port

2011-03-01 Thread Olivier Lefevre
On 3/1/2011 3:54 PM, Caldarale, Charles R wrote: Anything using an org.apache class is Tomcat-specific, and > therefore not portable. Oh, right. I had not picked up that LifecycleListener itself is a Catalina class. Still, the basic issue is not about the listener per se but how the app server

RE: Getting the Tomcat shutdown port

2011-03-01 Thread Caldarale, Charles R
> From: Olivier Lefevre [mailto:lefev...@yahoo.com] > Subject: Re: Getting the Tomcat shutdown port > Just to be 100% clear, this is a Tomcat thing, not a servlet > spec thing, right? Just wondering whether it's portable. Anything using an org.apache class is Tomcat-specific,

Re: Getting the Tomcat shutdown port

2011-03-01 Thread Mark Thomas
On 01/03/2011 14:46, Olivier Lefevre wrote: > On 3/1/2011 2:57 PM, Mark Thomas wrote: >> Providing you throw an Error, Tomcat is guaranteed not to start. > > OK! Just to be 100% clear, this is a Tomcat thing, not a servlet > spec thing, right? Just wondering whether it's portable. Yes, this is To

Re: Getting the Tomcat shutdown port

2011-03-01 Thread Olivier Lefevre
On 3/1/2011 2:57 PM, Mark Thomas wrote: Providing you throw an Error, Tomcat is guaranteed not to start. OK! Just to be 100% clear, this is a Tomcat thing, not a servlet spec thing, right? Just wondering whether it's portable. -- O.L.

Re: Getting the Tomcat shutdown port

2011-03-01 Thread Mark Thomas
On 01/03/2011 13:52, Olivier Lefevre wrote: > On 2/28/2011 8:18 PM, Mark Thomas wrote: >> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/security/SecurityListener.java?view=annotate >> > > This is brand new, isn't it? I can't find it in the 7.0.8 sources. Yes. > So it may thro

Re: Getting the Tomcat shutdown port

2011-03-01 Thread Olivier Lefevre
On 2/28/2011 8:18 PM, Mark Thomas wrote: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/security/SecurityListener.java?view=annotate This is brand new, isn't it? I can't find it in the 7.0.8 sources. So it may throw a java.lang.Error at Lifecycle.BEFORE_INIT_EVENT time but

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Olivier Lefevre
On 2/28/2011 6:09 PM, Caldarale, Charles R wrote: The servlet, or the webapp? The webapp in this case: the servlet that might fail is the "worker" servlet, the others more in a supporting role (e.g., UI). So if it fails the whole webapp should shut down. Why don't you simply throw a ServletEx

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Mark Thomas
On 28/02/2011 19:13, Olivier Lefevre wrote: > I know it's an interface I have to implement but without some > concrete class "close" to my problem to look at for guidance > LifecycleListener in and of itself does not help me much. Ah, OK. Try this: http://svn.apache.org/viewvc/tomcat/trunk/java/o

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Olivier Lefevre
On 2/28/2011 6:06 PM, Mark Thomas wrote: If you want to stop a single Servlet then Servlet.init() is the place to it. See section 2.3.2 of the Servlet 3.0 spec. I.e., the exception throwing approach suggested by C. Caldarale in the next answer. Yes, it's neat. So I was overcomplicating it. or

RE: Getting the Tomcat shutdown port

2011-02-28 Thread Caldarale, Charles R
> From: Olivier Lefevre [mailto:lefev...@yahoo.com] > Subject: Re: Getting the Tomcat shutdown port > > Your application may be on a shared Tomcat instance someday > > and System.exit is really bad in that case. > So let's kill the servlet instead. The servlet, or the

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Mark Thomas
On 28/02/2011 16:59, Olivier Lefevre wrote: >> Your application may be on a shared Tomcat instance someday >> and System.exit is really bad in that case. > > True. So let's kill the servlet instead. If you want to stop a single Servlet then Servlet.init() is the place to it. See section 2.3.2 of

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Olivier Lefevre
Your application may be on a shared Tomcat instance someday and System.exit is really bad in that case. True. So let's kill the servlet instead. But it's still unclear how you'd do that because from the ServletConfig you can get the ServletContext but from the ServletContext you can no longer ge

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Mark Thomas
On 28/02/2011 16:12, Olivier Lefevre wrote: >> Doing this from a servlet begs the question how you are going >> to restart it. > > Not an issue: I want to shut it down at startup if some needed > resources cannot be found. No pint restarting it then. Fair enough. I wouldn't do it in a Servlet.ini

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Olivier Lefevre
Doing this from a servlet begs the question how you are going to restart it. Not an issue: I want to shut it down at startup if some needed resources cannot be found. No pint restarting it then. I'm also curious why you want tot do this but System.exit() will have exactly the same result as us

Re: Getting the Tomcat shutdown port

2011-02-28 Thread Mark Thomas
On 28/02/2011 15:34, Olivier Lefevre wrote: > Is there a programmatic way to retrieve it from within > a webapp, more exactly from within Servlet.init()? I > can't find one. Same question for the actual command. > > As you may have guessed, I want to shut down Tomcat by > opening a socket and send

Getting the Tomcat shutdown port

2011-02-28 Thread Olivier Lefevre
Is there a programmatic way to retrieve it from within a webapp, more exactly from within Servlet.init()? I can't find one. Same question for the actual command. As you may have guessed, I want to shut down Tomcat by opening a socket and sending it a SHUTDOWN or whatever. Maybe there is a less lo