You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Leo Donahue - OETX <Le...@mail.maricopa.gov> on 2013/11/08 18:18:17 UTC

Host appBase

Tomcat 7.0.47

Reading over the security benchmark I posted a link to earlier, there is one that suggests to separate out the web content directory from the Tomcat system files.  Reading the Tomcat docs for appBase, I see I can set this value.

Reading further down in the Tomcat docs for Host, other questions have spawned... and I blame it on being Friday.

1.  When/Why would I change the xmlBase directory location?  For the same reasons I would change the appBase directory?

2.  What is the benefit of un-packing WAR files?
	a.  If you drop a WAR file into your webapps directory (appBase I guess), and it unpacks, should you leave the WAR file there or remove it?

3.  WAR files located outside of the Host's appBase will not be expanded...
	a.  Why would I deploy WAR files outside of the Host's appBase?
	b.  Where are those deployed?  By specifying the docBase?

4. What is the difference exactly between appBase and docBase?

If the Context is specified in server.xml, I can have an appBase and a docBase?  I know docBase has to be set outside of the Host's appBase, but why would I have two locations for WAR files?

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


Re: Host appBase

Posted by Milo Hyson <mi...@cyberlifelabs.com>.
On Nov 8, 2013, at 12:29 PM, Daniel Mikusa <dm...@gopivotal.com> wrote:

> … it is always nice to be able to adjust and customize things.

If there's value in doing so, certainly. But customizability generally comes at a cost. In addition to a more complicated implementation it tends to increase the potential for problems. Thus, one should assess the actual benefit of each new knob, they should weigh it against the consequences, and they should do so honestly.

- Milo Hyson
Chief Scientist
CyberLife Labs, Inc.


Re: Host appBase

Posted by Daniel Mikusa <dm...@gopivotal.com>.
On Nov 8, 2013, at 1:54 PM, Milo Hyson <mi...@cyberlifelabs.com> wrote:

> The term that immediately comes to mind is YAGNI. How many of these things have legitimate use-cases and how many are simply there because it was thought somebody somewhere someday *might* want to adjust them?

> /dev/null

I disagree with this statement.  The default settings in Tomcat are convenient and provide a good general environment for deploying applications, however it is always nice to be able to adjust and customize things.  With the exception of xmlBase, I've used all of the settings below on multiple occasions and I'm glad they exist.

> 
> - Milo Hyson
> Chief Scientist
> CyberLife Labs, Inc.
> 
> On Nov 8, 2013, at 9:18 AM, Leo Donahue - OETX <Le...@mail.maricopa.gov> wrote:
> 
>> Tomcat 7.0.47
>> 
>> Reading over the security benchmark I posted a link to earlier, there is one that suggests to separate out the web content directory from the Tomcat system files.  Reading the Tomcat docs for appBase, I see I can set this value.
>> 
>> Reading further down in the Tomcat docs for Host, other questions have spawned... and I blame it on being Friday.
>> 
>> 1.  When/Why would I change the xmlBase directory location?  

Can't say I've ever used this setting before.  The default has always worked nicely for me.  It's here for flexibility though.  For example if you would like to locate your xml context files outside of CATALINA_BASE or CATALINA_HOME.  Perhaps on a different disk or partition.

>> For the same reasons I would change the appBase directory?

I see this used occasionally.  Some users like to host their applications in a dedicated folder like "/my-apps".  Often on a different disk or partition.


>> 2.  What is the benefit of un-packing WAR files?

I'm not sure there's a concrete answer here.  Generally I see people unpack WAR files, but it's not a must.  One nice thing about having the WAR file exploded is that I can edit certain files without having to redeploy my application.


>> 	a.  If you drop a WAR file into your webapps directory (appBase I guess), and it unpacks, should you leave the WAR file there or remove it?

If Tomcat is running, you would leave it there unless you want to undeploy the application.  Then you would delete it.  

If Tomcat is not running, you could delete the WAR file.  If the exploded WAR directory still exists you could start Tomcat back up and run the application from it.  Running from an exploded WAR directory has some advantages like the WAR file doesn't need to be extracted on startup and you can edit certain files without needing to redeploy.


>> 3.  WAR files located outside of the Host's appBase will not be expanded...
>> 	a.  Why would I deploy WAR files outside of the Host's appBase?

This is a preference / customizability thing.  Some people prefer to deploy their applications to a custom folder like "/my-apps", but instead of pointing the entire appBase at this directory they'll use a context file in the xmlBase to deploy an application that is outside of the appBase.

One reason that I've personally used this is when developing software.  I set the docBase in a context file to point to the directory that contains the output from Maven.  Paired with the "reloadable" setting, this means that Tomcat will redeploy my application automatically when trigger a Maven build.


>> 	b.  Where are those deployed?  By specifying the docBase?

Files outside of the app base can be anywhere.  As you mentioned, you'd just point to them with the docBase.


>> 4. What is the difference exactly between appBase and docBase?

The appBase (configured on the Host tag, defaults to "webapps") points to a directory that can contain web applications to be deployed to Tomcat.  Any valid web app in that directory will get deployed.  

The docBase (configured on the Context tag) points to a directory or WAR file for one specific application.


>> If the Context is specified in server.xml, I can have an appBase and a docBase?

I wouldn't suggest adding Context tags in server.xml.  You can but it's not flexible and you need to restart Tomcat to make changes.  As far as appBase and docBase, you can specify both although they are specified on two different tags (Host vs Context).  When you specify a Context tag in server.xml, you need to specify a docBase.  You would never specify a docBase that points to an application residing under the appBase.  That would be bad.


>>  I know docBase has to be set outside of the Host's appBase, but why would I have two locations for WAR files?

Not sure I understand this question.  Perhaps you have multiple applications to deploy, some are located in the appBase and some are not.

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


Re: Host appBase

Posted by Milo Hyson <mi...@cyberlifelabs.com>.
The term that immediately comes to mind is YAGNI. How many of these things have legitimate use-cases and how many are simply there because it was thought somebody somewhere someday *might* want to adjust them?

- Milo Hyson
Chief Scientist
CyberLife Labs, Inc.

On Nov 8, 2013, at 9:18 AM, Leo Donahue - OETX <Le...@mail.maricopa.gov> wrote:

> Tomcat 7.0.47
> 
> Reading over the security benchmark I posted a link to earlier, there is one that suggests to separate out the web content directory from the Tomcat system files.  Reading the Tomcat docs for appBase, I see I can set this value.
> 
> Reading further down in the Tomcat docs for Host, other questions have spawned... and I blame it on being Friday.
> 
> 1.  When/Why would I change the xmlBase directory location?  For the same reasons I would change the appBase directory?
> 
> 2.  What is the benefit of un-packing WAR files?
> 	a.  If you drop a WAR file into your webapps directory (appBase I guess), and it unpacks, should you leave the WAR file there or remove it?
> 
> 3.  WAR files located outside of the Host's appBase will not be expanded...
> 	a.  Why would I deploy WAR files outside of the Host's appBase?
> 	b.  Where are those deployed?  By specifying the docBase?
> 
> 4. What is the difference exactly between appBase and docBase?
> 
> If the Context is specified in server.xml, I can have an appBase and a docBase?  I know docBase has to be set outside of the Host's appBase, but why would I have two locations for WAR files?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


Re: Host appBase

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Leo,

On 11/8/13, 12:18 PM, Leo Donahue - OETX wrote:
> Tomcat 7.0.47
> 
> Reading over the security benchmark I posted a link to earlier,
> there is one that suggests to separate out the web content
> directory from the Tomcat system files.  Reading the Tomcat docs
> for appBase, I see I can set this value.
> 
> Reading further down in the Tomcat docs for Host, other questions
> have spawned... and I blame it on being Friday.
> 
> 1.  When/Why would I change the xmlBase directory location?  For
> the same reasons I would change the appBase directory?
> 
> 2.  What is the benefit of un-packing WAR files? a.  If you drop a
> WAR file into your webapps directory (appBase I guess), and it
> unpacks, should you leave the WAR file there or remove it?
> 
> 3.  WAR files located outside of the Host's appBase will not be
> expanded... a.  Why would I deploy WAR files outside of the Host's
> appBase? b.  Where are those deployed?  By specifying the docBase?
> 
> 4. What is the difference exactly between appBase and docBase?

appBase is where webapps for a host generally live. You'll find WAR
files and expanded-WAR directories that will be deployed as contexts.
You can disable autoDeploy and deployOnStartup and then basically
appBase is no longer relevant (unless you just want to continue to use
it in that capacity, but use e.g. the Manager webapp to deploy
everything). You specify appBase in a <Host> element in server.xml.

docBase is the root of a specific webapp. Unless you put your
WAR/exploded-WAR-dir outside of Tomcat's autoDeploy directory (that
is, appBase), you generally don't have to specify this. You specify
docBase in a <Context> element in those places where <Context>s are
expected.

> If the Context is specified in server.xml, I can have an appBase
> and a docBase?

The context only has a docBase. appBase has no meaning for a single
context.

> I know docBase has to be set outside of the Host's appBase, but why
> would I have two locations for WAR files?

You might not want to auto-deploy. Or you may want to host Tomcat on
one disk but your webapp on another. There are lots reasons to put WAR
files in places other than the appBase but under normal circumstances,
you just drop your WAR file into the <Host>'s appBase and and call it
a day.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSfV2xAAoJEBzwKT+lPKRYztAP+wVWnKqn4FhpZUUzZdiNCu55
nhUAuc1yylOKamm/1N0gBNRow1aCupANEqhqbeufGeY2ocKkIdQB+32U4Cy18Brc
KBNFzh1fS7KA145rT/3OXeSp/zn+HvGpUupqF0PA7DM5C7PtJF5L7ae4J7gF8tqH
MJlfZM+WMTkd/MnAoxrJSyvicS81V5K0eGPqBwOljSRQu4uMhEeDlqLXdG2/IKrc
ajljTcKAyc9fOxU5Rv3HBmv5pp+IxPLWj4uA8Jq6Iegbsc65arFtabH47gezcV9R
gt+lxmZjdJIUJvDnV9092gyh2HJwU/ErS6X5tRLX+rnTdpCLxcpveywGlicdMEaj
2Lc2/SHoWleW2ufXNlK63u7P7WmFBGqGqqRuUa2QXEzCVd9DL+qd4phmzQeSfb9g
/Mz42klo0A04y224DEq0nekfZtGsXIAw4f+dtSXAp2HVtGG0oQnn3SPfKesWBBaz
LPhQjcBeliZk4Hr/5UC4KcU/F/ToonP9VFofmPe9lJ61u0gjXfo0TXN8VPWUYYp5
vZV6QrQgXyFaRfB2BXxArHpdNsczqCyA3aXVO9i5hj3b3QWpSsc4htf2Lsj1W/wm
VpC1A09tCsTN17IxY07+/ZDxNzQYuZjfOZoZVB2n+Y743zAw6hizvDCls7+AYSgR
vU6P3iS+B0jMzp5I+BnG
=5b7t
-----END PGP SIGNATURE-----

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


Re: Host appBase

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/11/8 Leo Donahue - OETX <Le...@mail.maricopa.gov>:
> Tomcat 7.0.47
>
> Reading over the security benchmark I posted a link to earlier, there is one that suggests to separate out the web content directory from the Tomcat system files.  Reading the Tomcat docs for appBase, I see I can set this value.
>
> Reading further down in the Tomcat docs for Host, other questions have spawned... and I blame it on being Friday.
>
> 1.  When/Why would I change the xmlBase directory location?  For the same reasons I would change the appBase directory?

Maybe you do not like the default naming,
or you do not want those to be in /conf,
or maybe you want to share them between installations or between
several <Host>s.

> 2.  What is the benefit of un-packing WAR files?

You can have direct access to those files. E.g. you can use
java.io.RandomAccessFile and other APIs that do not work with an
InputStream.

ServletContext.getRealPath(foo) returns a non-null.

The "sendfile" feature in Connectors needs direct access to files.

Note that in Tomcat 7 and earlier even it you run with
unpackWARs=false, the WEB-INF/*.jar files are unpacked into the
webapp's work directory.  It is easier for classloaders to work with
them this way. It is not so easy to read a file from a jar archive
that is packed into another archive.

>         a.  If you drop a WAR file into your webapps directory (appBase I guess), and it unpacks, should you leave the WAR file there or remove it?

Already answered by others.

> 3.  WAR files located outside of the Host's appBase will not be expanded...

Tomcat 6 did unpack them. Tomcat 7 does not unpack them, as we deemed
this as an useless feature.

Some small number of people complained after the change -- see mailing
list archives and Bugzilla issue 51294 for their stories.

>         a.  Why would I deploy WAR files outside of the Host's appBase?
>         b.  Where are those deployed?  By specifying the docBase?

yes, a docBase that points to a war file.

> 4. What is the difference exactly between appBase and docBase?
>
> If the Context is specified in server.xml, I can have an appBase and a docBase?

Already answered by others.

>  I know docBase has to be set outside of the Host's appBase,

Host's xmlBase and appBase are processed by auto-deployment and by
deploy-on-startup.

If they see you app in appBase, they will try to deploy it.  If at the
same time the same application is also deployed manually with an
explicit docBase  then you may end up with two copies of the same app.

Too many people got that wrong in the past, thus such warning was
added in documentation, and some protection was added in the code.

Best regards,
Konstantin Kolinko

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