You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Erick Lichtas <EL...@linoma.com> on 2012/02/10 16:38:15 UTC

programmatically determining connector startup failures

Hi everyone,

I'm using tomcat 6.0.32 on Windows 7.  I have an application where I programmatically start and stop a separate web application from within an already running tomcat application.  I do this by creating a new StandardService, setting the server as service.setServer(ServerFactory.getServer()) and creating/loading the connectors, engine, etc... all before calling service.start() to fire everything up.

Everything is working great, but I'm running into a small snag.  Should a connector of the service run into issues such as binding to a port, the StandardService.start() seems to swallow the exception.  It gets logged, but my caller to service.start() has no way handling that failure.

StandardService.java (~line 539)
try {
((Lifecycle) connectors[i]).start();
} catch (Exception e) {
log.error(sm.getString(
"standardService.connector.startFailed",
connectors[i]), e);
}

I've also looked into registering a LifecycleListener on the connector, but that doesn't won't tell me whether or not the start had completed.

Are there any other options, other than extending and for the most part duplicating the StandardService class, that might give me the ability to detect a failed connector startup?

Regards,

E R I C K   L I C H T A S
Linoma Software
Senior Software Engineer
p. 402.944.4242 x714
f. 402.944.4243
www.LinomaSoftware.com<http://www.linomasoftware.com/>
www.GoAnywhereMFT.com<http://www.goanywheremft.com/>


RE: programmatically determining connector startup failures

Posted by Erick Lichtas <EL...@linoma.com>.
Mark,

Thanks for the reply!  I am aware that there are changes to this in Tomcat 7 and will definitely get there, but will wait until we move to JSF 2.x (which is hopefully sooner than later).  

Unfortunately the start flag in the Connector will be true if connector.start() is called, regardless of the success of the operation, so isAvailable() will always return true in my case.

Regards

E R I C K   L I C H T A S
Linoma Software
Senior Software Engineer
p. 402.944.4242 x714
f. 402.944.4243
www.LinomaSoftware.com
www.GoAnywhereMFT.com


-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: Friday, February 10, 2012 9:55 AM
To: Tomcat Users List
Subject: Re: programmatically determining connector startup failures

On 10/02/2012 15:38, Erick Lichtas wrote:
> Hi everyone,
> 
> I'm using tomcat 6.0.32 on Windows 7.  I have an application where I 
> programmatically start and stop a separate web application from within 
> an already running tomcat application.  I do this by creating a new 
> StandardService, setting the server as
> service.setServer(ServerFactory.getServer()) and creating/loading the 
> connectors, engine, etc... all before calling service.start() to fire 
> everything up.
> 
> Everything is working great, but I'm running into a small snag.
> Should a connector of the service run into issues such as binding to a 
> port, the StandardService.start() seems to swallow the exception.
> It gets logged, but my caller to service.start() has no way handling 
> that failure.
> 
> StandardService.java (~line 539) try { ((Lifecycle) 
> connectors[i]).start(); } catch (Exception e) { 
> log.error(sm.getString( "standardService.connector.startFailed",
> connectors[i]), e); }
> 
> I've also looked into registering a LifecycleListener on the 
> connector, but that doesn't won't tell me whether or not the start had 
> completed.

connector.isAvailable() ?

> Are there any other options, other than extending and for the most 
> part duplicating the StandardService class, that might give me the 
> ability to detect a failed connector startup?

Upgrade to 7.0.x where all this was completely re-written?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: programmatically determining connector startup failures

Posted by Mark Thomas <ma...@apache.org>.
On 10/02/2012 15:38, Erick Lichtas wrote:
> Hi everyone,
> 
> I'm using tomcat 6.0.32 on Windows 7.  I have an application where I
> programmatically start and stop a separate web application from
> within an already running tomcat application.  I do this by creating
> a new StandardService, setting the server as
> service.setServer(ServerFactory.getServer()) and creating/loading the
> connectors, engine, etc... all before calling service.start() to fire
> everything up.
> 
> Everything is working great, but I'm running into a small snag.
> Should a connector of the service run into issues such as binding to
> a port, the StandardService.start() seems to swallow the exception.
> It gets logged, but my caller to service.start() has no way handling
> that failure.
> 
> StandardService.java (~line 539) try { ((Lifecycle)
> connectors[i]).start(); } catch (Exception e) { 
> log.error(sm.getString( "standardService.connector.startFailed", 
> connectors[i]), e); }
> 
> I've also looked into registering a LifecycleListener on the
> connector, but that doesn't won't tell me whether or not the start
> had completed.

connector.isAvailable() ?

> Are there any other options, other than extending and for the most
> part duplicating the StandardService class, that might give me the
> ability to detect a failed connector startup?

Upgrade to 7.0.x where all this was completely re-written?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org