Hi all,
I have started looking at how to embed tomcat in other applications using
the EmbededTomcat class.  After fighting with the classpath and classloaders
I seem to get it to work.  Along the way, I discovered that the addEndpoint
method seems to be broken.

When calling tomcat.addEndpoint(10088, InetAddress.getLocalHost(),
"localhost"); I get "IntrospectionUtils: Unable to resolve host
name:butterflies/193.217.13.99", which is pretty obvious.  The line

     setModuleProperty( mid, "address", addr.toString());

(line 477) should of course have been

     setModuleProperty( mid, "address", addr.getHostAddress());


The classpaths and classloaders in EmbededTomcat are also used somewhat
insistantly, especially in the initClassLoader method.  For example will
initClassLoader try to infer appsCP if it does not exists, but not commonCP.
containerCP, appsCP are not used outside this method.  commonCP is, but only
in the setCommonClassPath method, which does not have any container or apps
counterpart.

All in all, I find the EmbededTomcat class quite tricky to use when not
starting it from Main.  Are anyone working on the usability aspects of this
class?  It could be possible to just do:

  EmbededTomcat tomcat = new EmbededTomcat();

  tomcat.setInstall("....");
  // or even tomcat.setTomcatRoot("..."), or even let EmbededTomcat do some
of the initContext stuff before addModule is called

  tomcat.addEndpoint(8080);
  tomcat.addRootContext("....");

  tomcat.start();


Sincerely
Johannes Brodwall


Reply via email to