Hi there,
I have an application that uses Tomcat as embedded engine and so far I
was using version 5.5 of Tomcat. I wanted to upgrade to version 6.0.18
and I've found some issues due to the different behaviour and I don't
see any difference in the API or articles I've found so I wonder what
I'm doing wrong.

The first problem is that, after using Server.start(), unless I have
another living thread, the program will exit even though I have the
container started and supposedly listening on the port. I have tested
that the server indeed works and listens to that port, but when my
other threads finish, the container simply exists without a trace.
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?

On the other hand, 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. And I starting the server again does not "fix
it". On the other hand, with Tomcat 5.5 I am able to stop the server,
and it stops answering at the port, so I am also able to start it
again. Using exactly the same code.

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();
----------------------------------
Stopping it is quite simple:

    this.theEmbedded.stop();
----------------------------------

So, is the Tomcat 6 embedded engine broken or do I have to change the
code? Nothing in the API seemed to indicate any changes needed but...
who knows? :)

Thanks for your help,
D.

PD: I can provide more information like libraries used and log traces,
but I did not want to make this message too long, in case it was
something obvious I had missed.

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

Reply via email to