Using property files injected into a web archive file
You can inject several configuration files into the WAR file of a MobileFirst Server component.
You 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 MobileFirst Operations Console, MobileFirst Administration Services, and MobileFirst runtime:
- ibm.worklight.admin.environmentid
- ibm.worklight.topology.clustermode
- ibm.worklight.topology.platform
- ibm.worklight.admin.jmx.connector
- ibm.worklight.admin.jmx.dmgr.host
- ibm.worklight.admin.jmx.dmgr.port
- ibm.worklight.admin.jmx.host
- ibm.worklight.admin.jmx.port
- ibm.worklight.admin.jmx.user
- ibm.worklight.admin.jmx.pword
- ibm.worklight.admin.rmi.registryPort
- ibm.worklight.admin.rmi.serverPort
Injecting property files into a WAR file by 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:wljndiinject --sourceWarFile source.war testconf.properties prodconf.properties
The resulting web archive file can be found in the folder jndi-injected. It contains the property files inside the web archive file.
- --help
- Shows the help.
- --sourceWarFile file
- The web archive file that is 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; For details, see Creating a shared library of JNDI properties.
Injecting property files into a WAR file by using an Ant task
You can 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>
Installing 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 MobileFirst Administration Services, MobileFirst Operations Console, and the MobileFirst runtime, you can use the ant task to install the web archive files, or you can update the web archive files manually.
For details of how to install web archive files for MobileFirst components, see:- Using Ant tasks to install MobileFirst Server administration
- Deploying a project WAR file and configuring the application server with Ant tasks
- Deploying the Application Center WAR files and configuring the application server manually
When the web archive file is deployed, you must define the ibm.worklight.jndi.configuration property to point to the name of the required configuration.
Selecting 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, you 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.Selecting the configuration: WebSphere Application Server full profile
You must log in to the WebSphere® Application Server administration console and add the setting of the ibm.worklight.jndi.configuration property to the Java Virtual Machine custom properties.To add this property setting:
- Select .
- Select the name of your server.
- Expand "Java and process management" and select "Process Definition"
- Select "Java Virtual Machine".
- Select "Custom Properties" and click New.
- Specify the name as ibm.worklight.jndi.configuration.
- Specify the value as the name of the configuration.
- Click Apply.
- 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.
Selecting the configuration: WebSphere Application Server 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:
ibm.worklight.jndi.configuration=testconf
Alternatively, instead of editing the bootstrap.properties file, create or edit the $LIBERTY_HOME/usr/servers/worklightServer/jvm.options file. For example, add:
-Dibm.ibm.worklight.jndi.configuration=testconf
To enable the configuration, restart the web application server.
Selecting 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:
ibm.worklight.jndi.configuration=testconf
- On UNIX systems: $TOMCAT_HOME/bin/setenv.shFor example, add:
CATALINA_OPTS="$CATALINA_OPTS -Dibm.worklight.jndi.configuration=testconf"
- On Microsoft Windows systems: $TOMCAT_HOME/bin/setenv.batFor example, add:
set CATALINA_OPTS=%CATALINA_OPTS% -Dibm.worklight.jndi.configuration=testconf
To enable the configuration, restart the web application server.