|
Configuring OSGi
OSGi is a fundamental element in the technology stack of CQ5. It is used to control the composite bundles of CQ and their configuration.
OSGi "provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components. These components can be composed into an application and deployed".
This allows easy management of bundles as they can be stopped, installed, started individually. The interdependencies are handled automatically. Each OSGi Component (see the OSGi Specification) is contained in one of the various bundles. You can manage the configuration settings for such bundles by either:
OSGi Configuration Settings
The following lists OSGi configuration settings (according to bundle) that have been found to be relevant to project implementation. Not all the settings listed need adjusting, some are mentioned to help you understand how CQ operates.
Caution
The list is intended to act as a guideline and is not exhaustive.
The configuration necessary will vary from project to project.
Please see the Felix Console for values used and detailed information about parameters.
Apache Felix OSGi Management Console Configure:
- Plugins, the main navigation items (console plugins) to be available in the Apache Felix Web Management Console as top level menu items. Disable any you do not need as each requires space and resources.
Caution
If you are not using CRX then you should also configure:
- User Name and Password, the credentials for accessing the Apache Felix Web Management Console itself.
The password must be changed after the initial installation to ensure the security of your instance.
This is not needed if you are using CRX as the username and password properties are ignored if a WebConsoleSecurityProvider is used for authentication.
Note
This configuration should be made using the Felix Console as it is needed at startup - before the repository is available.
Apache Sling Customizable Request Data Logger Configure:
- Logger Name and Log Format to configure the location and format of request and access logging (default: request.log). This log file is essential when analyzing performance or debugging functionality related to the web chain.
This is paired with the Apache Sling Request Logger.
For further information see CQ Logging and Sling Logging.
Apache Sling Event Thread Pool Configure:
- Min Pool Size and Max Pool Size, the size of the pool used to hold event threads.
- Queue Size, the maximum size of the thread queue if the pool is exhausted.
The recommended value is -1 as this sets the queue to unlimited; if a limit is set then losses might occur when it is exceeded.
- Changing these settings can help performance in scenarios with a high number of events; for example, heavy CQ DAM or Workflow usage.
- Values specific to your scenario should be established using tests.
- These settings can affect the performance of your instance, so do not change them without reason and due consideration.
Apache Sling GET Servlet Configure some aspects of rendering:
- Auto Index to enable/disable directory rendering for browsing.
- Enable (or disable) default renditions, such as HMTL, Plain Text, JSON or XML.
You should not disable JSON.
Apache Sling JCR Installer
- Installation folders name regexp and Max hierarchy depth of install folders - specify where, and to which depth, repository folders are searched for resources to be installed. When a wildcard is used (as in .*/install) all appropriate matches will be searched, for example, /libs/sling/install and /libs/cq/core/install.
- Search Path, list of paths that jcrinstall searches for resources to be installed, together with a number indicating the weighting factor for that path.
These parameters probably do not need configuration, but can be useful to know when developing or debugging. For example the installation folder(s) can be useful for checking in/out or creating a package.
Apache Sling JSP Script Handler Configure performance relevant settings for the JSP script handler. To improve performance you should disable as much as possible.
In particular for production instances:
- disable Generate Debug Info
- disable Keep Generated Java
- disable Mapped Content
- disable Display Source Fragments
Apache Sling Java Script Handler Configure settings for the compilation of .java files as scripts (servlets).
Certain settings can affect performance, these should be disabled where possible, in particular for a production instance.
- Source VM and Target VM, define the JDK version as that used as the runtime JVM
- for production instances:
- disable Generate Debug Info
Apache Sling Job Event Handler Configure parameters that manage job scheduling:
- Retry interval, Maximum Retries, Maximum Parallel Jobs, Acknowledge Wait Time, amongst others.
- Changing these settings can improve performance in scenarios with a high number of jobs; for example, heavy usage of CQ DAM and Workflows.
- Values specific to your scenario should be established using tests.
- Do not change these settings without reason, only change after due consideration.
Apache Sling Logging Configuration Configure:
- Log Level and Log File, to define the location and log level of the central logging configuration (error.log). The level can be set to one of DEBUG, INFO, WARN, ERROR and FATAL.
- Number of Log Files and Log File Threshold to define the size and version rotation of the log file.
- Message Pattern defines the format of the log messages.
For further information see CQ Logging and Sling Logging.
Apache Sling Logging Logger Configuration (Factory Configuration) Configure:
- Log Level, Log File and Message Format to define details of the log file and messages.
- Logger to define the category; for example, only log for com.day.cq.
- By using Factory Configurations, any number of additional configurations can be added to cater with the various log levels and categories needed.
- Such configurations are helpful during development; for example, to log TRACE messages for a specific service in a specific log file.
- Such configurations are helpful in a production environment; for example, to have messages about a specific service logged to an individual log file for easier monitoring.
For further information see CQ Logging and Sling Logging.
Apache Sling Logging Writer Configuration (Factory Configuration) Configure:
- Log File to define the existence of a log file.
- Number of Log Files to define the version rotation.
- The writer can be used by a Apache Sling Logging Logger Configuration configuration.
- Such configurations are helpful during development; for example, to log TRACE messages for a specific service in a specific log file.
- Such configurations are helpful in a production environment; for example, to have messages about a specific service logged to an individual log file for easier monitoring.
For further information see CQ Logging and Sling Logging.
Apache Sling MIME Type Service Configure:
- MIME Types to add those required by your project to the system. This allows a GET request on a file to set the correct content-type header for linking the file type and application.
Apache Sling Main Servlet Configure:
- Number of Calls per Request and Recursion Depth to protect your system against infinite recursion and excessive script calls.
Apache Sling Referrer Filter To address known security issues with Cross-Site Request Forgery (CSRF) in CRX WebDAV and Apache Sling you need to configure the Referrer filter.
The referrer filter service is an OSGi service that allows you to configure:
- which http methods should be filtered
- whether an empty referrer header is allowed
- and a white list of servers to be allowed in addition to the server host.
See the Security Checklist - Issues with Cross-Site Request Forgery for further details.
Note
The Apache Sling Referrer Filter is dependent on the installation of a quick fix package.
Apache Sling Resource Resolver Configure central aspects of Sling resource resolution:
- Resource Search Path(s), add any project specific paths (but do not remove /libs or /apps).
- Virtual URLs to define your vanity URL mappings.
- URL Mappings to define any aliases; for example from /content to /.
- Mapping Location, the mapper configuration externalized in /etc/map.
- Use your local installation (for example, use http://localhost:4502/system/console/jcrresolver) to determine which Resource Resolver is active.
For further information see: http://cwiki.apache.org/SLING/flexible-resource-resolution.html.
Caution
In particular these options must be configured in the repository.
Otherwise changes made to URL Mappings using the Felix console might be overwritten by CQ upon the next startup.
Background Mailer These settings relate to the mailer that sends content-based mail messages created as cq:mailMessage in /var/mailer/messages. This effectively acts as a persistent mail queue for CQ and can also be used to configure a mailer within a cluster. The messages are deleted once sent. This is used for example, by the newsletter.
Configure:
- Scheduler period, the frequency with which to check for new mails available for sending.
- Mailer data root path, the location to be searched for new mail messages.
CQ Antispam Configure the anti-spam service (Akismet) used with the blog. This requires you to register the:
- Provider
- API key
- Registered URL
CQ HTML Library Manager Configure this to control the handling of client libraries (css or js); including, for example, how the underlying structure is seen.
- For production instances:
- enable Minify (to remove CRLF and whitespace characters).
- enable Gzip (to allow files to be gzipped and accessed with one request).
- disable Debug
- disable Timing
- For JS development (especially when firebugging/debugging):
- disable Minify
- enable Debug to separate the files for debugging and use with firebug.
- enable Timing in the case of interest in timing.
- enable Debug console to see JS console log messages.
Caution
When changing the setting for either Minify or Gzip you will also need to delete the contents of /var/clientlibs. This is a cached version of the clientlibs and will be rebuilt when next requested.
CQ Link Checker Service Check and if necessary configure:
- Scheduler Period to define the interval at which external links are to be automatically checked.
- Check Bad Link Tolerance Interval for the period after which an unsuccessful external link is considered bad.
- Link Check Override Patterns, to define any paths to be excluded from link checking.
CQ Link Checker Task Configure settings for a single link checker task (a task which checks an external link):
- Check the intervals defined in Good Link Test Interval and Bad Link Test Interval
- The various parameters related to proxies for internet access and NTLM that are needed for external access when checking a link.
CQ Page Processor Configure:
- Paths, a list of locations where the system listens for page modifications before triggering a jcr:Event.
CQ Replication Event Listener Configure:
- The Run Modes, in which replication events will be distributed to listeners. For example, if defined as author, then this is the system that will "initiate" the replication.
- The run mode publish needs to be added if the project code processes replication events (reverse replication) in a publish environment. For example, when the dispatcher is used to flush from the publish environment or when standard replication to other publish instances occurs.
CQ Repository change listener Configure:
- The Paths, locations to listen for repository events ready for distribution.
CQ Root Mapping Configure:
- Target Path to define where is a request to "/" will point to.
CQ WCM Debug Filter
- Disable this on production instances to ensure performance and security.
This is useful when developing as it allows the use of suffixes such as ?debug=layout when accessing a page. For example, http://localhost:4502/cf#/content/geometrixx/en/support.html?debug=layout will provide layout information that may be of interest to the developer.
CQ WCM Filter Configure:
- WCM Mode to define the default mode.
- On an author instance this might be edit, preview or design.
The other modes can be accessed from the sidekick, or the suffix ?wcmmode=disabled can be used to emulate a production environment.
- On a publish instance this must be set to disabled to ensure that no other mode is accessible.
CQ WCM Link Checker Configurator Configure:
- List of rewrite configurations to specify a list of locations for content-based linkchecker configurations. The configurations can be based on run mode; this is important to distinguish between author and publish environments, as linkchecker settings may differ.
CQ WCM Newsletter Configure the various settings used with the newsletter.
CQ WCM Page Statistics Configure:
- URL to send data to configure the URL used to track page statistics (is vital if a tracker request goes through the dispatcher); for example, the default is http://localhost:4502/libs/wcm/stats/tracker.
CQ WCM Version Manager Control if, and how, versions are managed in your system:
- Create Version on Activation, enabled in a standard installation
- Enable Purging
- Purge Paths, the paths that a search action will search
- Max Version Age, the maximum age (in days) of a version
- Max Number Versions, the maximum number of versions to keep
See Configuring Version Purge for more information.
CQ Workflow EMail Notification Service Configure the email settings for notifications sent by a workflow.
CRX Sling Client Repository Configure access to the underlying content repository.
- The Admin Password should be changed after installation to ensure the security of your instance.
- Other changes should not be necessary and care must be taken as they can affect access to the repository.
Note
This configuration should be made using the Felix Console as it is needed at startup - before the repository is available.
Day Commons GFX Font Helper When rendering graphics you can use DrawText to embed text. For this you can also install your own fonts:
- Define the Font Path to be searched for project specific fonts.
For example, /apps/myapp/fonts.
Day Commons HTTP Client 3.1 Proxy configuration for all code using the day commons HTTP client, used when a HTTP is made; for example upon replication.
The HTTP client in Day Commons is based on the Apache HTTP client.
Therefore it is recommended that developers use the HTTP client in Day Commons as opposed to writing their own or directly using the Apache HTTP commons.
HTTP Header Authentication Handler System wide settings for the basic authentication method of the HTTP request.
When using closed user groups you can configure (amongst others):
- HTTP Realm
- The Default Login Page
JDBC Connections Pool Configure access to an external database being used as a source for content.
This is a Factory Configuration, so multiple instances can be configured.
SSO Authentication Handler Configure Single Sign On (SSO) details; these are often needed in enterprise author setups, often in conjunction with LDAP.
Various configuration properties are available:
- Path
Path that this authentication handler will be used on. If this parameter is left empty the authentication handler is disabled.
- Header Names
The name(s) of headers that might contain a user ID.
- Cookie Names
The name(s) of cookies that might contain a user ID.
- Parameter Names
The name(s) of request parameters that might contain a user ID.
- ID Format
The format that the user ID is encoded with.
- Basic for the Basic format.
- AsIs if the value should be used "as is" or as a regular expression matched to provide the value.
For example, if you specify ^<DOMAIN>\\(.+)$ this will match against a header (cookie, parameter) starting with <DOMAIN>\ and followed by the user ID (where <DOMAIN> is replaced by your own domain name). The user ID is then used as the value for SSO. If you need to use groups in your regular expression, you can specify the group by appending |<group-index> to the regular expression (the group index starts with 1). So the above example can be written as ^<DOMAIN>\\(.+)$|1.
- Trusted Credential Attribute
The name of the attribute (in the trusted credentials) that is set with the user information.
Note: The value of Trusted Credential Attribute must be equal to the attribute you configure in repository.xml (by default <param name="trust_credentials_attribute" value="TrustedInfo"/>). This is the name of the Attribute used in the SimpleCredentials object to provide the userid from the SsoAuthenticationHandler to the authenticator CRXLoginModule. Therefore this has to be the same in the two configurations.
- Disable Login Page
This box is checked if the Login Page of this authenticator should be disabled. Usually:
- unchecked on author environments
- checked on publish environments
- HTTP Realm
Name of the HTTP realm, this is displayed in the login window seen by the user.
- Default Login Page
Absolute path of the page to use to display the default login form.
- Login Form Clients
Lists identifiers of clients which are known to support form based HTTP (Basic) authentication.
- UTF-8 Credentials
Lists the identifiers of clients that are known to encode non-ASCII credentials using UTF-8 character encoding.
Note
The Trusted Credential Attribute must be equal to the trust_credentials_attribute configured in the repository.xml (see Single Sign On).
Wiki Mail Service Configure the email settings for emails sent by a wiki.
OSGi Configuration in the Repository
To ensure that your configurations are safe for upgrade (or re-installation during testing) it is recommended to put all configuration details into the repository. This:
- allows you to easily configure your differing run modes.
- ensures that copying or replicating the repository contents recreates identical configurations.
- allows you to check configurations out to FileVault or Subversion; either for security or further updates.
- allows you to perform configuration rollouts using scripts to propogate the configuration details.
These configurations are made by creating sling:OsgiConfig nodes in the repository for the system to reference. These nodes mirror the OSGi configurations, and form a user interface to them. To update the configuration data you update the node properties.
If you modify the configuration data in the repository the changes are immediately applied to the relevant OSGi configuration as if the changes had been made using the Felix Web Management Console, with the appropriate validation and consistency checks. This also applies to the action of copying a configuration from /libs/ to /apps/.
As the same configuration parameter can be located in several places, the system:
- searches for all nodes of type sling:OsgiConfig
- filters according to service name
- filters according to run mode
Caution
- CRX Sling Client Repository
- Apache Felix OSGi Management Console
should be configured using the Felix Console as they are needed before the repository is available at startup. Any changes made to these will be held in configuration files.
Note
The order applied during startup is different to that applied during runtime.
Adding a New Configuration to the Repository
To add a new configuration to the repository you need to know the following:
- The Persistent Identity (PID) of the service.
Reference the Configurations field in the Felix console. The name is shown in brackets after the bundle name (or in the Configuration Information towards the bottom of the page).
For example, create a node com.day.cq.wcm.core.impl.VersionManagerImpl. to configure CQ WCM Version Manager. 
- Whether a specific run mode is required. Create the folder:
- config, for all run modes
- config.author, for the author environment
- config.publish, for the publish environment
- config.<run-mode>, as appropriate
- Whether a Configuration or Factory Configuration is necessary.
- The individual parameters to be configured; including any existing parameter definitions that will need to be recreated.
Reference the individual parameter field in the Felix console. The name is shown in brackets for each parameter.
For example, create a property versionmanager.createVersionOnActivation to configure Create Version on Activation.
- Does a configuration already exist in /libs? To list all configurations in your instance, use the Search functionality in the CRX Explorer to submit the following search:
select * from sling:OsgiConfig
If so this configuration can be copied to /apps/<yourProject>/, then customized in the new location.
Creating the Configuration in the Repository
To actually add the new configuration to the repository:
Using the CRX Explorer navigate to /apps/<yourProject>.
If not already existing, create the config folder (sling:Folder):
- config - applicable to all run modes
- config.<run-mode> - specific to a particular run mode
Under this folder create a node:
- Type: sling:OsgiConfig
- Name: the persistent identity (PID);
for example for CQ WCM Version Manager use com.day.cq.wcm.core.impl.VersionManagerImpl
Note
When making a Factory Configuration append -<identifier> to the name.
As in, org.apache.sling.commons.log.LogManager.factory.config-<identifier>,
where <identifier> is replaced by free text that you (must) enter to identify the instance (you cannot omit this information); for example, org.apache.sling.commons.log.LogManager.factory.config-MINE
For each parameter that you want to configure create a property on this node:
- Name: the parameter name as shown in the Felix Console; the name is shown in brackets at the end of the field description. For example, for Create Version on Activation use versionmanager.createVersionOnActivation
- Type: as appropriate.
- Value: as required.
You only need to create properties for the parameters that you want to configure, others will still take the default values as set by CQ.
Save all changes.
Changes are applied as soon as the node is updated by restarting the service (as with changes made in the Felix console).
Caution
You must not change anything in the /libs path.
Caution
The full path of a configuration must be correct for it to be read at startup.
Resolution Order at Startup
The following order of precedence is used:
- Repository nodes with type sling:OsgiConfig under /apps/*/config....
- Repository nodes with type sling:OsgiConfig under /libs/*/config....
- Any .config files from <cq-installation-dir>/crx-quickstart/launchpad/config/.... on the local file system.
So a generic configuration in /libs can be masked by a project specific configuration in /apps.
Resolution Order at Runtime
Configuration changes made while the system is running trigger a reload with the modified configuration.
Then the following order of precedence applies:
- modifying a configuration in the Felix console (not recommended) will take immediate effect as it takes precedence at runtime; but the change will be resolved according to the above order (lowest precedence) at the next restart.
- modifying a configuration in /apps will take immediate effect.
- modifying a configuration in /libs will take immediate effect, unless it is masked by a configuration in /apps.
The following list shows a small selection of the configurations available (by default) in the repository:
- Author - CQ WCM Filter:
libs/wcm/core/config.author/com.day.cq.wcm.core.WCMRequestFilter
- Publish - CQ WCM Filter:
libs/wcm/core/config.publish/com.day.cq.wcm.core.WCMRequestFilter
- Publish - CQ WCM Page Statistics:
libs/wcm/core/config.publish/com.day.cq.wcm.core.stats.PageViewStatistics
Note
As these configurations reside in /libs they should not be edited directly, but copied to your application area before customization.
To list all configurations in your instance, use the Search functionality in the CRX Explorer to submit the following search:
select * from sling:OsgiConfig
Using the Apache Felix Web Management Console
Apache Felix is a community effort to implement the OSGi R4 Service Platform, which includes the OSGi framework and standard services.
Caution
For most cases it is not recommended to make changes using the Felix console as these changes will not be written back to the repository.
Please use the repository for configuration. The console can be used for investigation purposes.
The exceptions to this rule are:
- CRX Sling Client Repository
- Apache Felix OSGi Management Console
as they are needed before the repository is available at startup. Any changes made to these will be held in configuration files.
Note
Comments on the Felix console about default settings relate to Sling defaults.
CQ has its own defaults and so the defaults set might differ from those documented.
The Apache Felix Web Management Console offers a selection of tabs for controlling the OSGi bundles:
Bundles: used for installing bundles
-
Components: used for controlling the status of components required for CQ5
-
Configuration: used for configuring the OSGi bundles, and is therefore the underlying mechanism for configuring CQ system parameters
Any changes made are immediately applied to the running system. No restart is required.
The console can be accessed from ../system/console/components; for example:
http://localhost:4502/system/console/components.
Parameters changed in the console are not saved in the repository, but under <cq-installation-dir>/crx-quickstart/launchpad/config. For this reason it is recommended to make all configuration changes in the repository itself.
The Bundles tab is the mechanism for installing the OSGi bundles required for CQ5.
Using this tab you can:
- Install or Update
- You can Browse to find the file containing your bundle and specify whether it should Start immediately and at which Start Level.
- Refresh Packages
- Refreshes the list displayed.
- Start
- Starts a bundle according to the start level specified.
- Stop
- Uninstall
- Uninstalls the bundle from the system.
- see the status
- The list specifies the current status of the bundle; clicking on the name of a specific bundle with show further information.
The Components tab allows you to Enable and/or Disable the various components.
Clicking on the name of a particular component will also display further information on its status.
Note
Enabling, or disabling, a component will only apply until CRX is restarted. The start state is defined within the component descriptor, which is generated during development and stored in the bundle at bundle creation time.
The Configuration tab is used for configuring the OSGi bundles, and is therefore the underlying mechanism for configuring CQ5 system parameters.

There are two types of configurations available from the drop down lists on this screen:
Configurations
Allows you to update the existing configurations. These have a Persistent Identity (PID) and can be either:
- standard and integral to CQ5; these are required, if deleted the values return to the default settings.
- instances created from Factory Configurations; these instances are created by the user, deletion removes the instance.
Factory Configurations
- Allows you to create an instance of the required functionality object.
- This will be allocated a Persistent Identity and then listed in the Configurations drop down list.
Selecting any entry from the lists will display the parameters related to that configuration.
You can then:
Save
Save the changes made.
- For a Factory Configuration this will create a new instance with a Persistent Identity. The new instance will then be listed under Configurations.
Reset
- Reset the parameters shown on screen to those saved last.
Delete
- Delete the current configuration. If standard, the parameters are returned to the default settings. If created from a Factory Configuration, then the specific instance is deleted.
Settings that are changed using the Felix console are saved in *.config files under:
/crx-quickstart/launchpad/config
In most cases you do not need to be aware of these as you will be making changes in the repository, not with the Felix console.
However, two bundles need to be configured with the Felix console as they are needed at startup - before the repository is available. It is useful to know the location of these configuration files so that copies can be taken for backup and/or multiple installation:
- Apache Felix OSGi Management Console
../crx/org/apache/felix/webconsole/internal/servlet/OsgiManager.config
- CRX Sling Client Repository
../com/day/crx/sling/client/impl/CRXSlingClientRepository/<pid-nr>.config
|
|
Alex