+

Search Tips   |   Advanced Search

Use property files injected into a web archive file

We can inject several configuration files into the WAR file of a MobileFirst Server component.

The property file can be injected into the web archive (WAR) files for operations console, MobileFirst administration service, MobileFirst runtime, or Application Center. This approach is useful when to transfer the configuration together with the web archive file to another web application server. In this case, you only have to handle the web archive file, and no other files. The configuration is, in this case, fused into the web archive file.

We can inject several different configurations into the same web archive file and then select in the web application server which configuration should be used. For example, you could have a test configuration and a production configuration injected at the same time. To do so, create multiple property files with different settings, one named testconf.properties and the other named prodconf.properties.

Some JNDI properties must have the same value in all MobileFirst Server components. Therefore, you should inject the same property files into all web archive files. The following JNDI properties must be the same for operations console, administrative services, and MobileFirst runtime:


Inject property files into a WAR file using the Command Line tool

The wljndiinject command line tool is used to inject a set of property files into a web archive file. To add the property files testconf.properties and prodconf.properties to a war file, use the following command:

The resulting web archive file can be found in the folder jndi-injected. It contains the property files inside the web archive file.

Options of the tool:

--help

Shows the help.

--sourceWarFile file

The web archive file used to add the property files.

--destFile file

The destination file name. If not specified, the destination file is placed in the jndi-injected directory.

--sharedJar

Used to create a shared library; See Create a shared library of JNDI properties.


Inject property files into a WAR file using an Ant task

Use the com.worklight.ant.jndi.JNDIInjectionTask Ant task to inject a set of property files into a web archive file.

Here is a sample ant script that shows the use of the ant task:

<?xml version="1.0" encoding="UTF-8"?>
<project name="WLJndiInjectTask" basedir="." default="jndiinject.Sample">
  <property name="install.dir" value="/path.to.worklight.installation" />
  <path id="classpath.run">
    <fileset dir="${install.dir}/WorklightServer/">
      <include name="worklight-ant-deployer.jar" />
    </fileset>
  </path>
  <target name="jndiinject.init">
    <taskdef name="jndiinject"
        classname="com.worklight.ant.jndi.JNDIInjectionTask">
      <classpath refid="classpath.run" />
    </taskdef>
  </target>
  <target name="jndiinject.Sample"
          description="Injects properties into the Worklight war file"
          depends="jndiinject.init">
    <!--  This is just an example:
        Mandatory parameters are sourceWarFile and the fileset.
        All other parameters are optional and could be ommitted.
        The source war files are expected in the wars directory.
        The property files are expected in the properties directory.
     -->
    <jndiinject
      sourceWarFile="wars/worklightproject.war"
      destWarFile="worklightproject-injected.war" >
        <fileset dir="." casesensitive="yes">
          <include name="properties/*.properties"/>
        </fileset>
    </jndiinject>
    <jndiinject
      sourceWarFile="wars/worklightadmin.war"
      destWarFile="worklightadmin-injected.war" >
        <fileset dir="." casesensitive="yes">
          <include name="properties/*.properties"/>
        </fileset>
    </jndiinject>
    <jndiinject
      sourceWarFile="wars/worklightconsole.war"
      destWarFile="worklightconsole-injected.war" >
        <fileset dir="." casesensitive="yes">
          <include name="properties/*.properties"/>
        </fileset>
    </jndiinject>
  </target>
</project>


Install the property-injected WAR files in the web application server

After injection of the property files into the web archive files, the web archive files contain the property files and can be installed like any normal web archive file in the web application server.

For the administrative services, operations console, and the MobileFirst runtime, we can use the ant task to install the web archive files, or we can update the web archive files manually. For details of how to install web archive files for MobileFirst components, see:

When the web archive file is deployed, we must define the ibm.worklight.jndi.configuration property to point to the name of the required configuration.


Select the configuration in a property-injected WAR file

The default configuration is called default.properties. If the configuration of JNDI properties has a different name, we must define the ibm.worklight.jndi.configuration property. The value of this property must be the configuration name without the extension .properties. This property can be specified as a Java Virtual Machine system property or explicitly as a JNDI property. This property cannot be defined in the configuration property file.


Select the configuration: WAS full profile

We must log in to the WebSphere Application Server administration console and add the setting of the ibm.worklight.jndi.configuration property to the JVM custom properties.

To add this property setting:

  1. Select Servers > Server types > WebSphere Application Servers.

  2. Select the name of the server.

  3. Expand "Java and process management" and select "Process Definition"

  4. Select "JVM".

  5. Select "Custom Properties" and click New.

  6. Specify the name as ibm.worklight.jndi.configuration.

  7. Specify the value as the name of the configuration.

  8. Click Apply.

  9. Click Save.

When the property is set, to enable the configuration, restart the appropriate MobileFirst Server components. These components are displayed in the WebSphere Application Server administration console under WebSphere enterprise applications.


Select the configuration: WAS Liberty profile

You must edit the $LIBERTY_HOME/usr/servers/worklightServer/bootstrap.properties file and set the ibm.worklight.jndi.configuration property to point to the name of the configuration.

For example:

Alternatively, instead of editing the bootstrap.properties file, create or edit the $LIBERTY_HOME/usr/servers/worklightServer/jvm.options file. For example, add:

To enable the configuration, restart the web application server.


Select the configuration: Apache Tomcat

You must edit the $TOMCAT_HOME/conf/catalina.properties file and set the ibm.worklight.jndi.configuration property to point to the name of the configuration.

For example:

Alternatively, instead of editing the catalina.properties file, depending on the operating system, create or edit one of the following files:

To enable the configuration, restart the web application server.


Parent topic: JNDI properties file for transfer