-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Nick,
On 3/12/13 11:50 PM, Nick Williams wrote: > > On Mar 12, 2013, at 10:47 PM, Nick Williams wrote: > >> The JavaDoc for o.a.c.startup.Tomcat [1] is not complete. >> Importantly, it is lacking complete information about all three >> addWebapp classes. You mean addWebapp methods? They seem fairly self-explanatory. >> Ultimately, I want to create one giant JAR file with my classes, >> Tomcat classes, servlet classes, etc., with a >> com.mycompany.Bootstrap specified as the Main class in >> MANIFEST.MF. I think is called OSGi, right? I think this has been done before... >> Here's (roughly) what I expect it to look like (though, if it >> should be different to make something work correctly, please >> correct me): >> >> - MyEmbeddedWebApp.jar - com - mycompany - ... - javax - ... - >> META-INF - MANIFEST.MF - org - apache - ... - web - index.html - >> WEB-INF - web.xml >> >> How do I correctly start up Tomcat so that my (lone) web app >> (MyEmbeddedWebApp.jar!/web/WEB-INF/web.xml) is correctly deployed >> to the root context (/) with index.html and etc. resources >> available? >> >> [1] >> http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/startup/Tomcat.html > >> > By the way, com.mycompany.Bootstrap currently looks like the code > below. It's the webAppDirLocation variable and addWebapp method > call that I'm struggling with. > > public class Bootstrap { public static void main(String... > arguments) throws Exception { String webAppDirLocation = "web/"; > Tomcat tomcat = new Tomcat(); tomcat.setPort(8973); > tomcat.addWebapp("/", new > File(webAppDirLocation).getAbsolutePath()); Tomcat.addWebapp(String,String) says that the first argument is the context path. The context path for the ROOT webapp is "", not "/". The second argument is a "baseDir" which says (via Context.setDocBase) it can be an absolute pathname, a relative pathname (to the cwd I suppose, or maybe relative to the hosts's appbase), or a URL. You are passing a relative path name which probably won't resolve to a resource "inside" the JAR file you are using. Try fetching a resource URL for the "web/" path from the ClassLoader and pass that instead of just "web/". You didn't say what actually happens: just stated your requirements and showed your code. Does Tomcat fail to start? Does it fail to listen on your port? Does it fail to respond to requests? > tomcat.start(); You should probably call tomcat.init() first, though some of the Tomcat test cases don't do it so you're probably okay. > tomcat.getServer().await(); } } I don't think you configured any logging. You might want to set up something to at least dump to the console, and crank-up the log level to DEBUG or something like that. Then you might be able to see what Tomcat is actually doing. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEAREIAAYFAlFAsxUACgkQ9CaO5/Lv0PBWTgCgol+RqJweJQ9VOiyAVcpJsxDg UoUAoI0AlgMh8IcJ2zm2lwDmzEDbovku =Prjq -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org