Can somebody please help me to setup a hello world example of embedded usage of tomcat 7 with servlet 3.0 support... I have a simple annotated HelloWorld servlet and would like to launch it from my eclipse environment. I have: tomcat-catalina.jar tomcat-servlet-api.jar tomcat-juli.jar tomcat-annotations-api.jar tomcat-api.jar tomcat-util.jar tomcat-coyote.jar on my test classpath which is "target/test-classes" and have my project on "target/classes"... I am using latest eclipse, java releases. Below is the code of where I am now... Thanks
import java.io.*; import org.apache.catalina.startup.*; public class EmbeddedTomcat { private final Tomcat server; public EmbeddedTomcat (final String host, final int port, final String contextPath, final String... classPaths) { final String tempPath = System.getProperty("java.io.tmpdir"); final File tempDirectory = new File(tempPath); System.setProperty("catalina.base", tempDirectory.getAbsolutePath()); final File appBase = new File(tempDirectory, "webapps"); appBase.mkdir(); server = new Tomcat(); server.setBaseDir(tempDirectory.getAbsolutePath()); server.getHost().setAppBase(appBase.getAbsolutePath()); server.setHostname(host); server.setPort(port); final File appDirectory = new File("target/test-classes", "webapps" + contextPath); server.addWebapp(null, contextPath, appDirectory.getAbsolutePath()); } public void start () throws Exception { server.start(); } public void stop () throws Exception { server.stop(); } public static void main (final String[] args) { final EmbeddedTomcat container = new EmbeddedTomcat("localhost", 8080, "/", "target/classes", "target/test-classes"); try { container.start(); System.in.read(); container.stop(); } catch (final Exception problem) { System.exit(100); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org