-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 2/15/15 10:33 AM, Mark Nichols wrote:
> I’m using Tomcat 7.0.59 on Ubuntu 12.04.4.
> 
> I’m also using Chef to manage the setup of the VM. The Chef
> resource I’m using to deploy my webapps produces a directory
> structure that looks like this:
> 
> ../webapps /foo /current ->
> /var/lib/tomcat7/webapps/foo/releases/2.1.0 /releases /2.1.0 / …
> 
> `current` is a symlink to the current version of the app.
> `releases` contains the current app and a prior version for
> rollback purposes.
> 
> In /etc/tomcat7/Catalina/localhost I have a context XML file named 
> “foo.xml” that has this as it’s contents:
> 
> <?xml version=“1.0” encoding=“UTF-8”?> <Context
> docBase=“/var/lib/tomcat7/webapps/foo/current” path=“/foo/app” />
> 
> When I start the container I get an error say
> 
> WARNING: A docBase /var/lib/tomcat7/webapps/foo/current inside the 
> host appBase has been specified, and will be ignored

Is your Tomcat host's appBase set to /var/lib/tomcat7/webapps? If so,
you don't want to put your web applications in there in the way you
have done. You'll end up deploying "foo" as a web application, which
is definitely not what you want: you'll be able to request
/foo/current/WEB-INF/web.xml for instance, and read your web
application's configuration.

> I’ve tried setting appBase inside the host declaration in my 
> server.xml to nothing (“”), and eliminating it entirely, both to no
> avail.

You'll end up with the default in some of those situations, which ends
up being the same as the explicit value.

> If I deploy the app under foo (eliminating the `releases`
> directory and the `current` symlink everything works as expected.

Yup. Exactly what I'd expect.

> How do I combine appBase and docBase to properly map my
> application? Can I not have the directory structure described
> above?

First, don't try to "combine" appBase and docBase. Try this:

1. Stop Tomcat
2. mkdir /var/lib/tomcat[7]?/my-webapps
3. mv /var/lib/tomcat7/webapps/foo /var/lib/tomcat[7]?/my-webapps
4. Edit /etc/tomcat7/Catalina/localhost/foo.xml:
   a. set docBase="/var/lib/tomcat[7]?/my-webapps/foo/current"
   b. Remove the "path" attribute
   c. Re-name foo.xml to "foo#app.xml"
   d. You may have to play-around with some of the symlink-related
      settings in your <Context> to get the symlink to work properly
5. Restart Tomcat

That /should/ do what you want it to do. Note that if you change the
symlink to point to a new version, it *may* trigger a re-load of the
web application if you have autoDeploy="true" in your <Host>.

Now, why does this work when your other configuration complained?
Well, Tomcat treats every .war file /and directory/ in the appBase
directory as a fully-fledged web application, even if it's not really
a web application (i.e. your 'foo' directory above, which is a bundle
of junk that contains one of more web application at various levels of
nesting).

So the solution is to move your big ball of stuff outside of where
Tomcat is looking to auto-deploy web applications. Then you use
foo#app.xml to specify the application to be available at the URL
space "/foo/app" and point Tomcat to the proper location of the actual
web application (which is foo/current, and not foo/ or
foo/releases/2.2.1, etc.). This way, Tomcat isn't auto-detecting the
wrong thing.

Oh, and why use foo#app.xml? That's an exercise for the reader:
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU4kpPAAoJEBzwKT+lPKRYRzYQAMBWcmi2UQrDgRlkudmQDV9j
1spgJCVgeKw7N00qgWxK3OSxcRvNnfBcHHPj5+IoFDSIeNI2gntFPE2sSNQJxboV
Q56jpqTfZNcopn93j+6kb1bEsF7+oAorKbzyI4lPMSG2fIQ/W9t3/OrCkn8SJm5V
Drr9IaN1aH9QUcjZrWwoMKKKgkmbrnxdkAewfkKMi40dwfE99L64NaLITJ5UP2Uw
noHGxqXtn14vPvAqpkwp9T69xwmarF+w95GkGMlxCLLKk2spD7QzQ6kiKTro0IbS
QKpRmvo3QM75zCyFHsDoxa0X3P/RXsFZKZr3NG63cct0I5S4RXhGr6HJJbmZPPxc
FUkqf0+SqHccejkplgJ6RSYiY4P7njc7rL59ADcbJ4B1cszpja45jkp/jWm8E5FV
tNZHP33zFJ9qwfmrUJ+vnQEYOTKOPROg3mGwddgVw9xxxk1Lvek3sOF37e1L1rry
CgUwoRuUfp3WYnnILCeTj9TqrpIurhFc6AB4Vm4NXUysXni1+xhXIDkCMLgJd3pK
wImHdTMHIILbU8OLnstoAgmYtr7/vU5KkT9WPgnUir75BybCbMJtyG3aeg89akY4
A8ocbmvBuwvReD3wJ8gbIIEKAsc0wTj8bOQARSjl9PxC6q9dVNtH5ONDkx/jYjT6
MQfIcgL8jjIHGcRnlpCz
=VoTy
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to