Hi Christopher, I've found a solution to my problem although I believe it's more accurate to say I guessed it :) Maybe you'll be able to explain it to me. Here is the complete code:
Tomcat tomcat = new Tomcat(); tomcat.setBaseDir(baseDir); tomcat.getConnector().setPort(8080); tomcat.getServer().setParentClassLoader(getClass().getClassLoader()); tomcat.getEngine(); // (1) tomcat.init(); tomcat.getHost().addAlias("127.0.0.1"); // (2) tomcat.start(); tomcat.addWebapp("", path); (1) - this seems like it should be called from somewhere within Tomcat class during initialization, but somehow it isn't called, and without this line I get a NullPointerException (2) - this is my solution to the problem I've described before; without this line my app is only served on http://localhost:8080 but if I include this line my app is available on http://localhost:8080, http://127.0.0.1:8080 and all other assigned addresses like http://192.168.1.1:8080 etc 2012/7/17 Christopher Schultz <ch...@christopherschultz.net> > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Alexander, > > On 7/17/12 6:42 AM, Alexander Shutyaev wrote: > > Ok, I've figured out it DOES listen on ALL addresses no matter > > what hostname is, but somehow requests only succeed if they have > > the hostname matching with the one set by Tomcat.setHostname(...) > > (which is localhost by default). I'm not sure where the requests > > fail, but they do. > > What happens when the requests don't "succeed"? > > If you have a connector bound to 0.0.0.0 (or ::) then it should accept > connections on any interface. > > If you have a Host defined that is the default, then it should respond > to all requests that don't match another Host. > > As long as you set the hostname before calling any of the more > interesting methods, then the hostname you specify should be the > default. If you set no hostname, then it will default to "localhost" > and will be *the default Host* so everything should work. > > Please describe in more detail what happens. Also, if you could post > your entire use of the Tomcat class, that would certainly help. > > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG/MacGPG2 v2.0.17 (Darwin) > Comment: GPGTools - http://gpgtools.org > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAlAFcLgACgkQ9CaO5/Lv0PCWCwCgidVx5uhVkpqk/rdSCnYeqbSl > wMcAnR3fk//7SHueaNwH5SLv8U+mGDnU > =C25J > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >