Menu

Tomcat Configuration

manual (35)
Timothy Anyona Timothy Anyona

Tomcat Configuration

Memory options

If you are using Tomcat as the application server, there are some configuration items you can set to improve performance. This is mainly setting Tomcat to run in server mode and increasing the amount of memory available to Tomcat e.g. so that jobs don't run out of memory.

Windows

If Tomcat was installed as a service

  • Run the TOMCAT_HOME\bin\tomcat8w.exe (or similar file for your Tomcat version). This may need to be run as administrator.
  • In the Java tab, in the Java Virtual Machine section, set Tomcat to run in server mode by changing the jvm.dll to the one in the JDK e.g. C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll
  • Increase the amount of memory available to Tomcat by setting a value in the Maximum memory pool textbox e.g. 1024 (this value shouldn't be very large compared to the total amount of memory available on the machine, otherwise the operating system and other applications may be starved of RAM)

Note:

  • The "service user account" configured to start and stop the Tomcat service needs to have appropriate permissions, otherwise you may get errors when accessing ART. In particular, ART requires write access to the ART_HOME\WEB-INF\work, ART_HOME\js-templates and ART_HOME\WEB-INF\thymeleaf directories.

If Tomcat is run from a batch file

  • Create a file named setenv.bat in the TOMCAT_HOME\bin directory (or edit it if it exists) and set the configuration options in the JAVA_OPTS environment variable e.g.

    set JAVA_OPTS=-server -Xmx1024m
    

Linux

Create a file named setenv.sh in the TOMCAT_HOME/bin directory (or edit it if it exists) and set the configuration options in the JAVA_OPTS environment variable e.g.

    export JAVA_OPTS="-server -Xmx512m"


Accessing Tomcat via Apache

You can use the Apache HTTP Server as a front end to your application that resides on Tomcat. This can be done for a number of reasons, including clustering or enabling access to the application from a more familiar url.

There are a number of ways to run Tomcat behind Apache.

Using mod_proxy

  • Ensure the following lines in your Apache httpd.conf file are uncommented

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    
  • Add an item at the end of the httpd.conf file to indicate how ART will be accessed by users and how Apache will communicate with Tomcat e.g

    ProxyPass /art http://localhost:8080/art
    ProxyPassReverse /art http://localhost:8080/art
    

That's it. Start Apache and Tomcat (the order of starting and stopping doesn't matter), and now you can access ART from the url localhost/art (i.e <apache-server>/art).

Using mod_proxy_ajp

If you have Apache 2.2 and above, you can use mod_proxy_ajp

  • Ensure the following lines in your Apache httpd.conf file are uncommented

    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    
  • Ensure you have an AJP connector defined in the TOMCAT_HOME\conf\server.xml file e.g.

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
  • Add an item at the end of the httpd.conf file to indicate how ART will be accessed by users and how Apache will communicate with Tomcat e.g

    ProxyPass /art ajp://localhost:8009/art
    ProxyPassReverse /art ajp://localhost:8009/art
    
  • Note that this definition uses the ajp protocol and port 8009, which is the port defined for the AJP connector in Tomcat's server.xml

That's it. Start Apache and Tomcat (the order of starting and stopping doesn't matter), and now you can access ART from the url localhost/art (i.e <apache-server>/art).

Using mod_jk

If you need more powerful proxying features, you can download, configure and use the mod_jk connector. This is slightly more involving than the other two methods already mentioned and you can use the instructions available at http://www3.ntu.edu.sg/home/ehchua/programming/howto/ApachePlusTomcat_HowTo.html to get it working.

Note:

  • For Ubuntu/Debian, instead of using LoadModule to enable the modules, use a2enmod from the command line, e.g.

    a2enmod proxy_ajp
    a2enmod proxy
    a2enmod proxy_http
    
  • Also for Ubuntu/Debian, add the ProxyPass and ProxyPassReverse items to the apache2.conf file instead of httpd.conf.


Related

Discussion: ART Error: Connection to the ART Repository is not available.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.