Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

README for Apache Fortress Realm Host Setup

  • Version 2.0.8
  • Apache Fortress Realm Host System Architecture Diagram Apache Fortress Realm Host System Architecture

Table of Contents

  • Document Overview
  • Tips for first-time users.
  • SECTION 1. Prerequisites.
  • SECTION 2. Prepare Tomcat for the Global Realm.
  • SECTION 3. Enable Tomcat Global Security.
  • SECTION 4. Enable Web App to use the Global Realm.
  • SECTION 5. Test with Tomcat Manager App (Optional).
  • SECTION 6. Common troubleshooting tips.
  • More on the Realm Proxy

Document Overview

This document describes how to enable global security inside Tomcat to use the Fortress Realm. To target setup for a single web application, w/out global security enabled, follow the instructions in the REALM-CONTEXT-SETUP instead.

Tips for first-time users

  • For a tutorial on how to use Apache Fortress check out the quickstarts in directory-fortress-core package.
  • For a tutorial on how to enable a Web application to use Fortress, check out the: README-ENABLE-FORTRESS.
  • If you see FORTRESS_CORE_HOME, refer to the base package of [directory-fortress-core].
  • If you see FORTRESS_REALM_HOME, refer to this packages base folder.
  • If you see TOMCAT_HOME, refer to the location of that package's base folder.
  • Questions about this software package should be directed to its mailing list:

SECTION 1. Prerequisites

Minimum hardware requirements:

  • 2 Cores
  • 4GB RAM

Minimum software requirements:

  • Java SDK 8++
  • Apache Tomcat7++
  • git
  • Apache Maven3++
  • Apache Fortress Core Download & Install in FORTRESS_CORE_HOME package
  • Apache Fortress Core Options for using Apache Fortress and LDAP server in FORTRESS_CORE_HOME package
  • Apache Fortress Realm Download & Install in this package's README.

Everything else covered in steps that follow. Tested on Debian, Centos & Windows machines.

SECTION 2. Prepare Tomcat for the Global Realm

  1. Stage the Fortress Realm Proxy jar.

Copy fortress-realm-proxy-[version].jar to TOMCAT_HOME/lib/ folder:

cp $FORTRESS_REALM_HOME/proxy/fortress-realm-proxy-[version].jar $TOMCAT_HOME/lib
  1. Configure the Fortress Realm for target LDAP server usage.

Copy the, created during FORTRESS_CORE_HOME setup, to this package's conf folder.

  1. Verify a match for target LDAP server coordinates.
# This param tells fortress what type of ldap server in use:

# ldap host name

# if ApacheDS is listening on

# If ApacheDS, these credentials are used for read/write to fortress DIT

# This is min/max settings for admin pool connections:

# This node contains more fortress properties stored on behalf of connecting LDAP clients:

# Used by application security components:

# Fortress uses a cache:

# Default for pool reconnect flag is false:
  1. Verify the configuration artifacts are present.
x@machine:~/FORTRESS_REALM_HOME/conf$ ls -l
-rwxrwxr-x 1 x y 5905 Jan 23 12:41 ehcache.xml
-rw-rw-r-- 1 x y 1161 Jan 23 12:41
-rw-rw-r-- 1 x y 1235 Jan 23 12:41 log4j2.xml

Fortress needs all three files.

SECTION 3. Enable Tomcat Global Security

  1. Edit TOMCAT_HOME/conf/server.xml:
vi $TOMCAT_HOME/conf/server.xml
  1. Comment out entry to UserDatabase:
<!--Resource name="UserDatabase" auth="Container"
   description="User database that can be updated and saved"
   pathname="conf/tomcat-users.xml" /-->
  1. Enable Tomcat global security to use the Fortress Realm. Add the following to the same file:
<Realm className=""

Here the FORTRESS_REALM_HOME conf folder and implementation jar are being declared to Tomcat server. Ensure that you stage these files outside of TOMCAT_HOME to ensure remaining clear of Tomcat's system classpath.

  1. Save and exit the editor.

  2. Restart Tomcat server to enable changes to take effect.

  3. Verify it worked:

tail -f -n10000 $TOMCAT_HOME/logs/catalina.out
... J2EE Tomcat7 policy agent initialization successful

SECTION 4. Enable Web App to use the Global Realm

  1. Edit the web app's deployment descriptor:
vi $MY_APP_HOME/src/main/webapp/WEB-INF/web.xml
  1. Add security constraints to the file:
     <display-name>Commander Security Constraint</display-name>
         <web-resource-name>Protected Area</web-resource-name>
         <!-- Define the context-relative URL(s) to be protected -->
         <!-- Anyone with one of the listed roles may access this area -->

 <!-- Example of HTTP Basic Authentication Setup. -->

 <!-- Security roles referenced by this web application -->

Fortress Realm follows standard Java EE security semantics.

  1. Redeploy web app to Tomcat.

  2. Login to the web app. Users that successfully authenticate and have role(s) listed in auth-constraint may access resources matching the url-pattern.

  3. Verify that the fortress realm is operating properly by viewing the Tomcat server log:

tail -f -n10000 $TOMCAT_HOME/logs/catalina.out
... J2EE Tomcat7 policy agent initialization successful

Realm Usage Notes:

  • Global security is now enabled under Tomcat.
  • This automatically enforces authentication and coarse-gained authorization (isUserInRole) checking.
  • Repeat steps in this section for each additional app to use Java EE security enforcement.

SECTION 5. Test with Tomcat Manager App (Optional)

This section provides instructions for using the Tomcat Manager application to test Apache Fortress Realm.

  1. Enable Tomcat Manager application. note: check the Tomcat documentation on how to do this.

  2. Verify/enable role name. Edit TOMCAT_HOME/webapps/manager/WEB-INF/web.xml

<!-- Security roles referenced by this web application --/>
    The role that is required to log in to the Manager Application
  1. Add and assign that role to a user.

  2. Test logon onto the Tomcat Manager app.

    Enter URL to manager web app: http://localhost:8080/manager/html

    Enter creds (tcmanager, password) into basic logon form Verify authentication/authorization success to web app.

SECTION 6. Common troubleshooting tips

  1. Server can't find config files (realmClasspath=FORTRESS_REALM_HOME/conf")
Jul 15, 2011 8:21:16 PM us.jts.sentry.tomcat.Tc7AccessMgrProxy initialize
INFO: us.jts.sentry.tomcat.Tc7AccessMgrProxy.initialize - instantiate policy agent name: us.jts.sentry.tomcat.TcAccessMgrImpl
2011-07-15 20:21:17,053 (FATAL) us.jts.configuration.Config static init: Error, null configuration file:
Jul 15, 2011 8:21:17 PM us.jts.sentry.tomcat.Tc7AccessMgrProxy startInternal
SEVERE: us.jts.sentry.tomcat.Tc7AccessMgrProxy.startInternal caught Throwable=java.lang.ExceptionInInitializerError
       at us.jts.sentry.J2eePolicyMgrFactory.<clinit>(
       at us.jts.sentry.tomcat.TcAccessMgrImpl.<init>(
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
       at java.lang.reflect.Constructor.newInstance(
       at java.lang.Class.newInstance0(
       at java.lang.Class.newInstance(
       at us.jts.sentry.tomcat.Tc7AccessMgrProxy.initialize(
       at us.jts.sentry.tomcat.Tc7AccessMgrProxy.startInternal(
       at org.apache.catalina.util.LifecycleBase.start(
       at org.apache.catalina.core.ContainerBase.startInternal(
       at org.apache.catalina.core.StandardEngine.startInternal(
       at org.apache.catalina.util.LifecycleBase.start(
       at org.apache.catalina.core.StandardService.startInternal(
       at org.apache.catalina.util.LifecycleBase.start(
       at org.apache.catalina.core.StandardServer.startInternal(
       at org.apache.catalina.util.LifecycleBase.start(
       at org.apache.catalina.startup.Catalina.start(
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(
       at java.lang.reflect.Method.invoke(
       at org.apache.catalina.startup.Bootstrap.start(
       at org.apache.catalina.startup.Bootstrap.main(
Caused by: java.lang.RuntimeException: us.jts.configuration.Config static init: Error, null configuration file:
       at us.jts.configuration.Config.<clinit>(
       ... 25 more

ACTION: Ensure realm classpath points to Fortress configuration folder that contains config file.

  1. Server can't find proxy jar (Realm className=“”)
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path...
Apr 22, 2011 10:24:04 PM org.apache.tomcat.util.digester.Digester startElement
SEVERE: Begin event threw exception

ACTION: Ensure fortress-realm-proxy jar copied to TOMCAT_HOME/lib folder.

  1. Server can't find binaries (realmClasspath=“FORTRESS_REALM_HOME/impl/target/fortress-realm-impl-uber-[version].jar”)
Apr 22, 2011 10:22:25 PM initialize
SEVERE: Fortress Tomcat Realm.initialize java.lang.ClassNotFoundException=java.lang.ClassNotFoundException:
Apr 22, 2011 10:22:25 PM start
SEVERE: Fortress Tomcat Realm.start caught Exception=java.lang.RuntimeException: Fortress Tomcat Realm.initialize java.lang.ClassNotFoundException=java.lang.ClassNotFoundException:
java.lang.RuntimeException: Fortress Tomcat Realm.initialize java.lang.ClassNotFoundException=java.lang.ClassNotFoundException:

ACTION: Ensure realm classpath points fortress-realm-impl-uber jar, i.e. FORTRESS_REALM_HOME/impl/target/fortress-realm-impl-uber-[version].jar.

  1. Incompatible Tomcat Proxy jar loaded for Tomcat 6 and before.

The Fortress Realm requires Tomcat version's 7 and beyond. If you are running Tomcat 4, 5 or 6 and see error that looks like this:

SEVERE: An exception or error occurred in the container during the request processing
java.lang.RuntimeException: detected Fortress Tomcat7 Realm not initialized correctly.  Check your Fortress Realm configuration
       at org.apache.catalina.authenticator.FormAuthenticator.authenticate(
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
       at org.apache.catalina.core.StandardHostValve.invoke(
       at org.apache.catalina.valves.ErrorReportValve.invoke(
       at org.apache.catalina.core.StandardEngineValve.invoke(
       at org.apache.catalina.connector.CoyoteAdapter.service(
       at org.apache.coyote.http11.Http11Processor.process(
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

ACTION: Install and use Tomcat version 7 and later in your target machine.

More on the Realm Proxy

The fortress realm proxy jar contains a shim that uses a URLClassLoader to reach its implementation libs. It prevents the realm impl libs, contained within this package, from interfering with Tomcat's system classpath thus providing an error free deployment process w/out classloader issues. The realm proxy offers the flexibility for each web app to determine its own version/type of security realm to use, satisfying a variety of requirements related to web hosting and multitenancy.