View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Installation/Custom/Apache Tomcat

Tomcat

Contents

Apache Tomcat Requirements

Openbravo needs the Apache Tomcat to be installed and configured.

For the specific versions supported and the currently recommended version check the System Requirements.

User account for running tomcat / compiling

Conceptually there are two user accounts involved in working with Openbravo:

There are several overlapping areas in which one of the accounts needs to access and modify files from the other account in both directions.

To avoid any problems Openbravo strongly recommends to run Apache Tomcat services with the same user account which is used on command line. As that way the above topic will be perfectly solved easily.

Download and install Apache Tomcat

Apache Tomcat distribution can be downloaded from the official project page.

To install it extract the archive to a folder on your system. Make sure that all files are owned the by main user 'openbravo' as explained above.

Bulbgraph.png   Downloading Tomcat distribution instead of taking packaged version from i.e. a Linux Distribution has the downside of not having a init script and not having it integrated into the boot process. Init scripts are quite custom to the i.e. linux system being used so creating one is up to the system administrator and not explained in this guide.

Environment variables to configure

Three environment variables must be configured for correct operation:

Tomcat config files to modify

Changes to conf/context.xml

Two changes are required to the context.xml file:

In order to avoid Tomcat from auto-reloading itself, comment out the WatchedResource line:

<!-- <WatchedResource>WEB-INF/web.xml</WatchedResource> -->

Disable session persistence as it is not supported and cannot work with Openbravo. For this activate the following config which is present but commented in the tomcat default installation:

<!-- <Manager pathname="" /> -->

Changes to conf/server.xml for development use

As "development use" here is meant a simple installation of tomcat without another http server like Apache Webserver in front of it.

The AJP connector on port 8009 active by default in tomcat download should be activated. For this its entry should be commented out.

Optionally disable the tomcat access log if you do not want to have a access log file with one line for every http request. To do this disable the AccessLogValve entry present by default in tomcat distribution.

Changes to conf/server.xml for production use

Production use here means a Apache HTTP server in front of tomcat to take care of several extra tasks as:

Having a webserver in front means the direct http connector on port 8080 of tomcat is not used and should be disabled by commenting out its entry.

<!-- <Connector port="8080" redirectPort="8443" connectionTimeout="20000" protocol="HTTP/1.1"/> -->

This guide assumes the Apache HTTP webserver is installed on the same server, so the connector port 8009 should be restricted to be accessible only locally.

In the AJP Connector on port 8009 add the following attribute:

Also disable the builtin tomcat access log as the Apache server in front of it has one also with more information already. For this comment out the following line:

<!-- <Valve className="org.apache.catalina.valves.AccessLogValve" pattern="%h %l %u %t "%r" %s %b" suffix=".txt" prefix="localhost_access_log." directory="logs"/> -->

Remove other tomcat default webapps

Default ships several web-application by default in its webapps folder:

A typical openbravo installation does not require any of those. To slim-down / lock-down the installation those should be removed by deleting their folders from tomcat webapps directory.

If a custom install should want to keep any of those access control should be put in place to avoid any unauthorized usage.

Example Install on Ubuntu 18.04 LTS

Get direct download link for latest tomcat 8.5.x from tomcat page.

Download tomcat to /opt/tomcat

sudo su -  
cd /tmp
wget <copied_link_address>
tar xvf apache-tomcat-<version>.tar.gz
mv /tmp/apache-tomcat-<version> /opt/tomcat
chown openbravo: -R /opt/tomcat

Configure the required environment variables:

sudo su -
# set CATALINA_OPTS
echo 'export CATALINA_OPTS="-server -Djava.awt.headless=true -Xms384M -Xmx1024M"' > /etc/profile.d/tomcat.sh
 
# set CATALINA_HOME and CATALINA_BASE
echo 'export CATALINA_HOME=/opt/tomcat' >> /etc/profile.d/base-variables.sh
echo 'export CATALINA_BASE=/opt/tomcat' >> /etc/profile.d/base-variables.sh

Apply required config file changes

sudo su -
# Apply config changes as per documentation above (for production use)
vim /opt/tomcat/conf/context.xml
vim /opt/tomcat/conf/server.xml

Not having an init-script allow to start / stop tomcat using the following. It is important to always us the correct user account to start / stop tomcat!

sudo su - openbravo
cd /opt/tomcat
# to start
bin/startup.sh
# to stop
bin/shutdown.sh



Example install of Apache Tomcat on Microsoft Windows

Bulbgraph.png   This section was written for an older version and it outdated. It is kept as a reference but should not be just used 'as written'
  1. Download and install Apache Tomcat.
  2. The download you want is the 32-bit/64-bit Windows Service Installer, as that will integrate it as Windows Service.
    1. Run that installer.
    2. It will ask if it should install several optional components (documentation, manager application, host manager application, example application). Openbravo does not need any of those they should not be marked.
    3. For the port configuration the rest of the guide assumes the standard ports 8005, 8080, 8009.
  3. Add CATALINA_HOME, CATALINA_BASE and CATALINA_OPTS environment variables:
    1. Right-click on My Computer.
    2. Select Properties. The system properties window appears.
    3. Select the Advanced tab.
    4. Click Environment Variables.
    5. Click New. The New System Variable box appears.
    6. In the Variable name field, type CATALINA_HOME.
    7. In the Variable value field, type the path of the Apache Tomcat installation directory. This is usually C:\Apache Software Foundation\Tomcat 7.0.
    8. Click OK.
    9. Click New. The New System Variable box appears.
    10. In the Variable name field, type CATALINA_BASE.
    11. In the Variable value field type %CATALINA_HOME%.
    12. Click OK
    13. Click New. The New System Variable box appears.
    14. In the Variable name field, type CATALINA_OPTS.
    15. In the Variable value type -server -Djava.awt.headless=true -Xms384M -Xmx1024M.
  4. Configure values in the tomcat service manager application. After the installation there will be a new icon in the windows System Tray which can be used to start / stop the tomcat service and also configure it.
    1. In the configure window, go to the Java tab
      1. Add -server -Djava.awt.headless=true to the end of the Java Options
      2. Change the Initial Memory Pool to 384M
      3. Change the Maximum Memory Pool to 1024M

As you will have noticed that item 4 above makes sure that the settings just done now match the ones done via the CATALINA_OPTS variable.

If you change any one of the two later it is important to edit then in both places.

Bulbgraph.png   More information about managing environment variables in Microsoft's Help & Support site
Bulbgraph.png   Known issue (for releases before 3.0PR15Q1)

16452: On Windows Openbravo won't start if the installation path contains a space

  1. In order to avoid Tomcat from auto-reloading itself, comment the WatchedResource line in C:\Apache Software Foundation\Tomcat 7.0\conf\context.xml:
    <!-- <WatchedResource>WEB-INF/web.xml</WatchedResource> -->
  2. On startup Tomcat will try to load active session from before last shutdown again. As that is not supported and cannot work with Openbravo switch it off by uncommenting the following line in the same context.xml file:
    <!-- <Manager pathname="" /> -->

You can check that Tomcat is running by opening http://localhost:8080 in a web browser.

Installing for development use (non production)

As development use here is meant a simple installation of tomcat without another Http server like Apache in front of it.

In addition to the global config above the following changes should be done.

  1. In the config/server.xml file of tomcat comment out the Connector entry for AJP on port 8009 as that is not useful without a Apache server in front of it.
  2. For the Http Connector on port 8080 add the following attribute to it:
    1. URIEncoding="UTF-8"
  3. Optionally disable the tomcat access log if you do not want to have a access log file with one line for every http request. For this comment out the following line:
<!-- <Valve className="org.apache.catalina.valves.AccessLogValve" pattern="%h %l %u %t "%r" %s %b" suffix=".txt" prefix="localhost_access_log." directory="logs"/> -->

Installing for production use

Production use here means a Apache HTTP server in front of tomcat to take care of several extra tasks as:

In addition to the global config above the following changes should be done.

  1. In the config/server.xml file of tomcat comment out the Http Connector entry for port 8080 as it will not be used at all.
<!-- <Connector port="8080" redirectPort="8443" connectionTimeout="20000" protocol="HTTP/1.1"/> -->
  1. For the AJP Connector on port 8009 add the following two attributes to it:
    1. URIEncoding="UTF-8"
    2. address="localhost"
  2. Also disable the builtin tomcat access log as the Apache server in front of it has one also with more information already. For this comment out the following line:
<!-- <Valve className="org.apache.catalina.valves.AccessLogValve" pattern="%h %l %u %t "%r" %s %b" suffix=".txt" prefix="localhost_access_log." directory="logs"/> -->

How to use the installed Tomcat

This questions tries to address some frequently asked questions.

Retrieved from "http://wiki.openbravo.com/wiki/Installation/Custom/Apache_Tomcat"

This page has been accessed 66,054 times. This page was last modified on 22 October 2018, at 11:34. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.