You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kevin Jackson <fo...@gmail.com> on 2009/05/07 10:38:29 UTC

tomcat6 configuration best practice?

Hi,

I'm currently trying to understand the best practices for tomcat6
application deployments given certain restrictions:
1 - We deploy exploded dirs only, not WAR files
2 - We need to be able to hot deploy jsps (but not classes/jars)
without restarting tomcat
3 - The application must be the ROOT or base webapp

Environment:
- RedHat Enterprise 4
- tomcat 6.0.18
- sun jdk 1.6.u012
- apache httpd 2.0.2 (with redhat bug fixes etc - I'm uncertain what
the exact version is)
- mod_jk (latest)
- apr 1.3.3 (built from src)
- apr-util 1.3.4 (built from src)
- libtcnative (latest)
- using tomcat-jdbc connection pool implementation after commons-dbcp
failed under high load and c3p0 also failed - recommended by one of
the tomcat developers

Currently we have the following
$CATALINA_HOME/webapps/
- app
- ROOT -> app

$CATALINA_HOME/conf/Catalina/localhost/
- app.xml
- ROOT.xml -> app.xml

Where our app is symbolically linked to ROOT.xml and a ROOT dir respectively.

In my previous tomcat6 experience, I've deployed war files, either by
hand or using a custom maven plugin. So I'm a little unsure if our
current configuration is broken.  I suspect we may be causing the
container to attempt to load the application twice - but I'd like some
confirmation.

I think the following structure would be more managable and probably
better for tomcat too:

$CATALINA_HOME/conf/Catalina/localhost/
- ROOT.xml -> /deployments/app.xml

/deployments/
- app.xml
- app

Again where the ROOT.xml is a sumbolic link

The Context configuration to achieve this separation of the
application from the tomcat directory structure I presume would look
something like:

<Context path="/" docBase="/deployments/app" debug="1"
reloadable="true" cookies="true">
  <Environment
    name="####"
    value="####"
    type="java.lang.String"
    override="false"/>

  <Environment
    name="SEARCH-SERVICE_URL"
    value="####"
    type="java.lang.String"
    override="false"/>

  <Resource
    name="jdbc/####"
    scope="Shareable"
    type="javax.sql.DataSource"
    auth="Container"
    username="####"
    password="####"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    driverClassName="net.sourceforge.jtds.jdbc.Driver"
    url="jdbc:jtds:sqlserver://#####"
    removeAbandoned="true"
    logAbandoned="true"
    maxActive="150"
    maxIdle="30"
    minIdle="20"
    initialSize="20"
    maxWait="10000"
    validationQuery="SELECT count(1) from #####"
    />

  <Resource
    name="mail/Session"
    auth="Container"
    type="javax.mail.Session"
    mail.smtp.host="localhost"/>
</Context>

One thing I think we can change for sure is the debug="true"
parameter, but given the requirement to allow us to hot deploy jsp
files (but not jars or classes), can we change reloadable to false?
The documentation suggests that this very resource intensive and I
would like to remove it "it requires significant runtime overhead and
is not recommended for use on deployed production applications" [1]

Any other suggestions to the application context, or server xml warmly
welcomed :)

Thanks,
Kev
[1] http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

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


RE: tomcat6 configuration best practice?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Kevin Jackson [mailto:foamdino@gmail.com]
> Subject: Re: tomcat6 configuration best practice?
> 
> We are using httpd as we serve *many* static files too

Tomcat will server static files every bit as well as httpd (especially since you're using APR).

> Do we need both the context.xml file and the exploded application
> directory structure?

You need the <Context> element to define the <Resource> elements used by the webapp.  Whether the webapp is deployed as a .war file or exploded directory is irrelevant.  When you have a conf/Catalina/[host]/[appName].xml file, the webapp's META-INF/context.xml file is ignored.

> just the application directory (which we can name as ROOT)

Naming the directory (or .war file) ROOT is only applicable when the webapp is deployed under the <Host> appBase directory.  Since you're not deploying your webapp under appBase, the name can be anything you choose; it's the name of the .xml file under conf/Catalina/[host] that determines the webapp path.

Make sure you delete any existing ROOT directory (or ROOT.war file) from the <Host> appBase directory.

> Can you explain why it would be so wrong to have a symlink at all?

I find them to be a significant maintenance issue - easily forgotten when you decide to move things around.  Your deployment process (script) should just copy the <Context> element to conf/Catalina/[host]/ROOT.xml and eliminate the potential for problems.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: tomcat6 configuration best practice?

Posted by Kevin Jackson <fo...@gmail.com>.
> Why are you using httpd?  If everything is being forwarded to Tomcat, adding httpd just slows things down and makes your life more complicated.

We are using httpd as we serve *many* static files too and not every
request is being forwarded to Tomcat - we have our reasons for using
apache as a front end webserver.

>> Currently we have the following
>> $CATALINA_HOME/webapps/
>> - app
>> - ROOT -> app
>
> Bad practice - your app will be deployed twice.  Just call it ROOT and be done with it.

As I suspected - removing this will improve our memory usage considerably

>> $CATALINA_HOME/conf/Catalina/localhost/
>> - app.xml
>> - ROOT.xml -> app.xml
>
> More bad practice; just use ROOT.xml and get rid of the silly symlinks.

Do we need both the context.xml file and the exploded application
directory structure?  The documentation isn't clear (to me) if they
are both required or just the application directory (which we can name
as ROOT)

> Why are you insisting on making things more complicated?  Just use a ROOT.xml in the proper place.  Stop confusing things with the symlinks.
>

Can you explain why it would be so wrong to have a symlink at all?

>> <Context path="/" docBase="/deployments/app" debug="1"
>
> The path attribute is not allowed (and you've got an invalid value for it); remove it.

Ok

>> given the requirement to allow us to hot deploy jsp files (but not
>> jars or classes), can we change reloadable to false?
>
> Yes, you can set reloadable to false; the monitoring of .jsp changes is controlled by the jsp servlet settings in conf/web.xml, not by the reloadable attribute of the <Context> element.

Thanks,
Kev

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


RE: tomcat6 configuration best practice?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Kevin Jackson [mailto:foamdino@gmail.com]
> Subject: tomcat6 configuration best practice?
> 
> - apache httpd 2.0.2

Why are you using httpd?  If everything is being forwarded to Tomcat, adding httpd just slows things down and makes your life more complicated.

> Currently we have the following
> $CATALINA_HOME/webapps/
> - app
> - ROOT -> app

Bad practice - your app will be deployed twice.  Just call it ROOT and be done with it.

> $CATALINA_HOME/conf/Catalina/localhost/
> - app.xml
> - ROOT.xml -> app.xml

More bad practice; just use ROOT.xml and get rid of the silly symlinks.

> I suspect we may be causing the container to attempt to load the 
> application twice - but I'd like some confirmation.

Yes, that's what's happening.  Don't use the symlinks.

> I think the following structure would be more managable and probably
> better for tomcat too:
> 
> $CATALINA_HOME/conf/Catalina/localhost/
> - ROOT.xml -> /deployments/app.xml

This is better, but I still wouldn't use the symlink.  Just put the ROOT.xml file where it belongs.

> /deployments/
> - app.xml
> - app

Why are you insisting on making things more complicated?  Just use a ROOT.xml in the proper place.  Stop confusing things with the symlinks.

> <Context path="/" docBase="/deployments/app" debug="1"

The path attribute is not allowed (and you've got an invalid value for it); remove it.

> given the requirement to allow us to hot deploy jsp files (but not 
> jars or classes), can we change reloadable to false?

Yes, you can set reloadable to false; the monitoring of .jsp changes is controlled by the jsp servlet settings in conf/web.xml, not by the reloadable attribute of the <Context> element.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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