You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Johannes Brodwall <jo...@brodwall.com> on 2001/09/19 14:58:19 UTC

Using EmbededTomcat embeded in another application - addEndpoint

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



Re: Using EmbededTomcat embeded in another application - addEndpoint

Posted by cm...@yahoo.com.
> 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.

Well, at least we're trying to self-configure/infer as much as possible,
the code is not perfect - I added what was needed to improve what I
believed to be the common use case.

The goal was to minimize the user effort - and if you look at
EmbededTomcat.main(), it's close to what you request. ( I suppose we're
discussing the curret 3.3 code ).

Please send sugestions, I'm very interested in feedback and improvements
in this area. Right now the 'Main' works fine ( or at least better than
before :-), I was able to use EmbededTomcat standalone ( i.e. using the
main() ) and even without server.xml file.

Costin

> 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
>