> From: d.lope...@gmail.com [mailto:d.lope...@gmail.com] On Behalf Of
> Daniel Lopez
> Subject: Tomcat 5.5 embedded vs Tomcat 6.0.18 embedded
> 
> when my other threads finish, the container simply exists 
> without a trace.

The metaphysical implications of existing without a trace are rather 
intriguing...

> I've seen a thread in the tomcat-dev list ("embedded tomcat 6" 14 Feb
> 2008) that seems to imply this is normal with Tomcat 6, but in Tomcat
> 5.5 this did not happen. Is this normal?

Looks like it.  In Tomcat 5.5, there was a non-daemon thread for each 
<Connector> named "http-<port>-Monitor"; this thread no longer exists in 6.0, 
since the whole area appears to have been re-architected.  There are no 
non-daemon threads in Tomcat 6.0, other than the whatever thread gets the game 
started; the normal Tomcat bootstrap uses this lead thread to listen on the 
shutdown port.  You'll need to have some thread hanging around to keep the JVM 
from terminating; if you don't have such a thread, why are you bothering with 
embedded?

> if I start the server with a GUI window, so the container 
> remains alive due to the GUI thread, stopping the server
> does not really work, as even though it says that the 
> Connector stopped, I can still access the server for some
> seconds and then it starts answering "resource not available",
> but the thing is, it still answers to the port.

It's your responsibility to terminate your GUI thread so the JVM can kill off 
all the daemon threads.

> The code looks like this:
> ----------------------------------
>     this.theEmbedded = new Embedded();
>     this.theEmbedded.setCatalinaHome(new File("tomcat_6").getAbsolutePath());
>     // Add the engine
>     this.engine = this.theEmbedded.createEngine();
>     this.engine.setName("Catalina");
>     this.engine.setDefaultHost("localhost");
>     // Create the host
>     this.host = this.theEmbedded.createHost("localhost", ".");
>     this.engine.addChild(this.host);
>     this.theContext = this.theEmbedded.createContext("/",
> this.theConfiguration.getBasePath());
>     this.theContext.setReloadable(false);
>     this.host.addChild(this.theContext);
>     this.theEmbedded.addEngine(this.engine);
>     // Add a conector
>     this.connector =
> this.theEmbedded.createConnector((java.net.InetAddress) null,
> this.port, false);
>     this.theEmbedded.addConnector(this.connector);
>     this.theEmbedded.start();

You really use "this." everywhere?  Seems a bit tedious, to say nothing of 
making code reviews difficult.

> So, is the Tomcat 6 embedded engine broken or do I have to 
> change the code?

You have to change your code; you got lucky in 5.5.

> Nothing in the API seemed to indicate any changes needed

Yes, the doc could be improved here.  You could create a FAQ/Wiki entry based 
on your findings.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


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

Reply via email to