Tomcat Configuration

From Plex-XML
Jump to: navigation, search

Contents

Tomcat Port

The default port for http servers is 80. Tomcat defaults to using port 8080 instead to avoid an installation of tomcat automatically being seen as a public web server. If you don't have or plan to install any other web server on your PC you could put the Tomcat-Service on port 80 in place of the default port 8080. Then you don't have to put the port after each URL.

You can change tomcat's default port by editing the conf/server.xml file. Look for the following Connector definition near the top of the file:

 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
  <Connector port="8080" maxHttpHeaderSize="8192"
   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
   enableLookups="false" redirectPort="8443" acceptCount="100"
   connectionTimeout="20000" disableUploadTimeout="true" />

Other options

A list of other options we sometimes use:

-Dcatalina.base=D:\Apache\Tomcat8180
-Dcatalina.home=D:\Apache\Tomcat8180
-Djava.endorsed.dirs=D:\Apache\Tomcat8180\endorsed
-Djava.io.tmpdir=D:\Apache\Tomcat8180\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=D:\Apache\Tomcat8180\conf\logging.properties
-Dhttp.proxyHost=proxy.de.mydomainname.net
-Dhttp.proxyPort=1919
-Dhttp.nonProxyHosts=localhost|127.0.0.1|*.mydomainname.net
-Dcom.sun.management.jmxremote
-XX:MaxPermSize=256m

Log-Files

There are different log files in your Tomcat-Logs directory that could give some useful informations about problems or errors in your implementation.

  • stdout.log
  • stderr.log
  • admin.log

You should check these files if you application won't act as expected.

Using Tomcat with different server names

In order to have Tomcat available with another name than the original server name the following steps have to be taken:

  1. Map the new server name in your DNS server
  2. Enter a new host entry into your server.xml file in your Tomcat instance. For example: <Host name="finance.toepfer.net" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"/>
  3. Create a new folder inside your conf\Catalina folder with the name of the server. For example finance.toepfer.net
    1. Put the applications context.xml file into the new folder. For example Finance.xml
    2. If the application should run in the root directory of the new server tha path attribute in the context node has to be empty. For example <Context docBase="Financial" path="" reloadable="false" privileged="false" debug="0">


Der Pfad im docBase-Attribut ist relativ zum appBase-Verzeichnis in Schritt 2 angelegten Host-Nodes in der server.xml. Wahlweise kann auch ein absoluter Pfad angegeben werden.

Java.lang.OutOfMemoryError: PermGen space

This error may occur when the JVM runs out of space in the permanent generation heap.


If the application(s) in the server use a large number of classes, the solution is to increase the value specified with -XX:MaxPermSize.

Try to use -XX:MaxPermSize=256m in the Java options of your Tomcat.

See Eclipse_installation#OutOfMemoryError for a more detailed JVM-Memeory description

Using UTF-8 within URLs

By default, Tomcat uses ISO-8859-1 character encoding when decoding URLs received from a browser. This can cause problems when encoding is UTF-8, and you are using international characters in attachment or page names. When using UTF-8 (recommended) you should enable Tomcat to decode such URLs. To do so, you should add an attribute 'URIEncoding="UTF8"' to the <Connector ...>-Element(s) in your server.xml

  • Edit conf/server.xml and find the line where the Connector is defined. It will look something like this:
 <Service name="Catalina">
  <Connector port="8080" protocol="HTTP/1.1"/>
  ...
  • Add a 'URIEncoding="UTF-8"' property to the connector:
  ...
  <Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8"/>
  ...
  • Restart your Tomcat

If your are using mod_jk ...

You should also apply the same URI-Encoding parameter as above to the AJP connector:

 <Connector port="8009" protocol="AJP/1.3" URIEncoding="UTF-8"/>

Links to other Tomcat configuration pages

Configuration of Context.xml

New Tomcat on a Mac

  • set security so tomcat could be started e.g. from Eclipse with Ant
  • memory settings in /bin/catalina.sh:
JAVA_OPTS="$JAVA_OPTS -Xms512m -Xmx2048m -XX:MaxPermSize=512m"
  • set tomcat user in conf/tomcat-users.xml
<role rolename="tomcat"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="xxx" roles="tomcat,manager,manager-gui,admin,admin-gui"/>
  • set headless in ../conf/catalina.properties
java.awt.headless=true
Personal tools