Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3
minLevel3

Setting up the runtime environment

To configure class loading, you should add the class loading configuration in a file named webapp-classloading.xml and place it in the META-INF directory of a web application. All the artifacts related to a web application are saved in the following directory: <PRODUCT_HOME>/repository/deployment/server/<Web_Application_Type>/<Web_Application_Name>. For example: <PRODUCT_HOME>/repository/deployment/server/webapps/SampleApp.

...

  • Shown below is the webapp-classloading.xml file configuration to specify CXF as the runtime environment:

    Code Block
    languagehtml/xml
    <Classloading xmlns="http://wso2.org/projects/as/classloading">
       <Environments>CXF</Environments>
    </Classloading>
  • Shown below is the configuration to specify 'Javaee' as the runtime environment. The support for Javaee is provided along with Apache TomEE. If you use the Javaee runtime, then TomEE should also be configured in AS as explained here.

    Code Block
    languagehtml/xml
    <Classloading xmlns="http://wso2.org/projects/as/classloading">
       <Environments>Javaee</Environments>
    </Classloading>
  • You might want to access some Carbon features in a CXF application. To achieve this, specify a comma-separated list of environments in webapp-classloading.xml file. The following example specifies both CXF and Carbon as the runtime environments:

    Code Block
    languagehtml/xml
    <Classloading xmlns="http://wso2.org/projects/as/classloading">
       <Environments>Spring,Carbon</Environments>
    </Classloading>

Configuring TomEE

The following configurations are required if the Javaee runtime is enabled for your AS as explained above. There are two Apache TomEE configurations:

  1. Set the default tomee configurations: Open the tomee.xml file located in the <AS_HOME>/repository/conf/tomee/ directory and configure Datasources, Resources etc.

  2. Set the jvm system properties that will be used by TomEE: Open the system.properties file located in the <AS_HOME>/repository/conf/tomee/ directory. For a comprehensive list of system properties, see http://tomee.apache.org/properties-listing.html.

Extending the runtime environments

This section explains how to place your external dependencies in a running server. This allows you to share dependencies with a number of applications without packaging them with each and every application. To do this, place the common dependencies in the relevant directories given below.

...

Info

Practice caution when placing dependency files in Tomcat environment's ext directory as those dependencies will be visible to all other environments. For example, if you place incompatible Spring dependencies in the <PRODUCT_HOME>/lib/runtimes/ext directory, it can cause problems with the existing Spring dependencies in the CXF runtime environment.

If there are such incompatible dependencies, the recommended best practice is to package them with the web application in the Tomcat environment itself. Libraries that are only used by a particular web application can be put into the <webapp_name>.war/WEB-INF/lib directory.

Adding Custom Runtime Environments

To define custom runtime environments, add a new element as <ExclusiveEnvironments> in the <PRODUCT_HOME>/repository/conf/tomcat/webapp-classloading-environments.xml file.  

...

Info

Note that adding custom runtime environments to your system without studying their impact can cause unfavorable results. For example, assume an Application Server (AS) instance contains the following configurations.

  • CXF (runtime provided by AS) contains CXF 2.7.5 and Spring 3.0.7 dependencies.

  • Spring (custom runtime) contains Spring 3.2.1 dependencies.

If a web application consumes both of the above environments, the following problems will arise:

  1. The web application's classpath contains dependencies from two Spring versions as 3.0.7 and 3.2.0. The Spring project does not recommend this as it will cause several classloading issues.

  2. CXF 2.7.5 itself uses Spring 3.0.7. It is possible that a particular CXF version is not properly tested for compliance with another version of Spring. You should study the CXF project recommendations to find a suitable Spring version.

Upgrading Existing Runtime Environments

The CXF runtime environment comes by default with core CXF 2.7.5 and core Spring 3.0.7 dependencies. If you want to upgrade to a different CXF version, there are two recommendations:

...