I have used a variation of the embedded tomcat example code from the onjava site (http://www.onjava.com/pub/a/onjava/2002/04/03/tomcat.html?page=1).
The problem I am having is that I can not get the WAR file auto-deploy mechanism to work the way that it does in stand-alone Tomcat. The functionality that I am trying to get is to have Tomcat 4.1.12 unpack the WAR files in the webapps directory so that the URL to access the WAR file contents is the name of the WAR file. For example, say that I have a WAR file named "CoolStuff.WAR". This WAR file contains tag libraries that are in JAR files, jsp pages and html pages. It contains a file called "index.html" that is in the root directory of the WAR file. In standalone Tomcat when you place this WAR file in the webapps directory, to access the index.html file you would load the following URL: http://localhost:8080/CoolStuff/ , but using the embedded Tomcat you run into problems. If you use it as is, the WAR file in the webapps directory does not expanded, so you have to do one of three things (as far as I can tell so far): 1. Change the example so that these lines: // Create the ROOT context Context context = embedded.createContext("", getPath() + "/webapps/ROOT"); host.addChild(context); read: // Create the ROOT context - not really anymore Context context = embedded.createContext("", getPath() + "/webapps"); host.addChild(context); 2. Add a HostConfig LifeCycleListener: HostConfig hConfig= new HostConfig(); ... host.addLifecycleListener(hConfig); 3. Upgrade to Tomcat 4.1.18 and use the StandardHost APIs to deployWebApps: // Create a default virtual host host = (StandardHost) embedded.createHost("localhost", tempPath.toString()); host.setUnpackWARs(true); host.setAutoDeploy(true); None of these solutions provide the same functionality that stand-alone Tomcat does, so I am still searching for a solution that does. The problem with the first solution is that the ROOT context can not be added with "", which means that you have type out ROOT in the URL. Which is different than stand-alone Tomcat. The problem with the second solution is that you get errors when the WAR file unpacks, because the JAR files won't unpack properly. It seems to be related to this issue: http://www.mail-archive.com/[email protected]/msg37181.html that does not appear to be fixed yet. The problem with the second solution is that although the WAR files get deployed, the WAR file name is not used in the URL, so in the example stated above instead of loading the "index.html" file from http://localhost:8080/CoolStuff/ it would load from http://localhost:8080/ which is not the way stand-alone tomcat works. It seems to me like there should be a simple solution to this, but I have not found one yet (besides not using embedded Tomcat). Any help would be appreciated. Thank you, George --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
