This was blogged earlier this week.. http://copperykeenclaws.wordpress.com/2010/08/19/embedding-tomcat-7/ I'll be using this info for the Red5 plugin very soon..
<http://copperykeenclaws.wordpress.com/2010/08/19/embedding-tomcat-7/>Paul On Wed, Aug 4, 2010 at 2:34 AM, David Calavera <david.calav...@gmail.com>wrote: > Hi, > > I don't know if that's your problem but I use the method server.await to > allow the server to wait. > > On Mon, Aug 2, 2010 at 2:32 PM, Marzia Forli <marzia.fo...@yahoo.com> > wrote: > > > 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 > > > > > -- http://gregoire.org/ http://code.google.com/p/red5/ http://code.google.com/p/blue5/