tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Länzlinger" <>
Subject More info - WAR File loaded into embedded Tomcat not reachable
Date Fri, 27 Apr 2007 19:02:04 GMT
Hello again,

Here the code i wrote to start embedded tomcat and load a war-file, and following also the

Maybe: Does a physical web.xml must exist on the filesystem, as i have none and use this call
<setDefaultWebXml("web.xml")> ? 
Also, in none of all the folders is my web-application extracted as i´m being uses with the
norml tomcat.

Thanks for any input, Greetings Max

import org.apache.catalina.Connector;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.startup.Embedded;

public class WebAppServer implements {

	private String baseDir;
	private String workDir;
	private boolean started = false;
	private Embedded tomcat = null;

	public WebAppServer() {
		this.baseDir = "c:\\temp";
		System.setProperty("catalina.home", baseDir);
	public void close () throws {
		try  {
		catch (org.apache.catalina.LifecycleException e) {
			throw new;

	public boolean isStarted() {
		return this.started;

	public void start() throws Exception {
    	if (!this.isStarted()){   		
        this.tomcat = new Embedded();

        Engine engine = this.tomcat.createEngine();
        String appBase = this.baseDir +"\\apps";
        StandardHost host =
        (StandardHost)this.tomcat.createHost("localhost", appBase);

        URL myurl = new URL("file:"+this.baseDir+ "\\mynewwar.war");
         host.install("", myurl);
        Context context = host.findDeployedApp("");
        ((StandardContext)context).setWorkDir(this.workDir + 

        Connector connector = tomcat.createConnector((String)null, 
                                                      8085, false);
        this.started = true;
    	else {
    		System.out.println("Tomcat already started!");

	public void stop() throws Exception {
	   	if (this.tomcat !=null){   		
		this.started = false;

CONSOLE: Embedded Tomcat starts fine, loads the war-file obviously, but why cant i call it
and nowhere is a extracted war-file?.. 

27.04.2007 20:52:28 org.apache.catalina.core.StandardHost getDeployer
INFO: Create Host deployer for direct deployment ( non-jmx ) 
27.04.2007 20:52:28 org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path  from URL file:c:/temp/mynewwar.war
27.04.2007 20:52:28 org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
27.04.2007 20:52:28 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.0.30
27.04.2007 20:52:28 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
27.04.2007 20:52:28 org.apache.catalina.startup.ContextConfig defaultConfig
INFO: No default web.xml
27.04.2007 20:52:28 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8085
27.04.2007 20:52:28 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8085

"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message