Using a shared library of JNDI properties
You can create a shared library to hold different configurations for any MobileFirst Server component.
You can add several different configurations to the same shared library and then select in the web application server which configuration to use. For example, you could have a test configuration and a production configuration injected at the same time. To do so, create property files with different settings, one named testconf.properties and the other prodconf.properties.
Installing a shared library of JNDI configurations
Assume that all web applications are already installed. The shared library is added to the web applications.- WebSphere® Application Server full profile
- Determine a suitable directory for the shared library jndiprops.jar in
the WebSphere Application Server installation
directory and place the jndiprops.jar file there.
- For a stand-alone server, you can use a directory such as:
$WAS_INSTALL_DIR/optionalLibraries/IBM/Worklight
- For deployment to a WebSphere Application Server ND
cell, use for example:
$WAS_INSTALL_DIR/profiles/profile-name/config/cells/cell-name/Worklight
- For deployment to a WebSphere Application Server ND
cluster, use:
$WAS_INSTALL_DIR/profiles/profile-name/config/cells/cell-name/clusters/cluster-name/Worklight
- For deployment to a WebSphere Application Server ND
node, use:
$WAS_INSTALL_DIR/profiles/profile-name/config/cells/cell-name/nodes/node-name/Worklight
- For deployment to a WebSphere Application Server ND
server, use:
$WAS_INSTALL_DIR/profiles/profile-name/config/cells/cell-name/nodes/node-name/servers/server-name/Worklight
For details about adding the shared library, see Adding the shared library (WebSphere Application Server full profile).
- For a stand-alone server, you can use a directory such as:
- WebSphere Application Server Liberty profile
- Place the jndiprops.jar file in a suitable
directory; for example,$LIBERTY_HOME/usr/shared/resources/lib/jndiprops.jar.
Edit the $LIBERTY_HOME/usr/servers/worklightServer/server.xml file. For each <application> element, add or update the <classloader> element.
<application ...> ... <classloader delegation="parentLast"></p> ... <privateLibrary> <fileset dir="${shared.resource.dir}/lib" includes="jndiprops.jar"/> </privateLibrary> </classloader> </application>
Restart the web application server after these changes.
- Apache Tomcat
- Place the shared library, jndiprops.jar file,
in a suitable directory; for example, $TOMCAT_HOME/Worklight/jndiprops.jar.
Edit the $TOMCAT_HOME/conf/server.xml file. For each <Context> element, add or update the <Loader> element.
<Context docBase="worklightconsole" path="/worklightconsole"> <Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${catalina.base}/Worklight/jndiprops.jar" searchVirtualFirst="true"/> … </Context>
For the MobileFirst project, which uses additional shared libraries, the example code is:
<Context docBase="worklightconsole" path="/worklight"> <Loader className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${catalina.base}/Worklight/worklight/worklight-jee-library.jar;${catalina.base}/Worklight/jndiprops.jar" searchVirtualFirst="true"/> … </Context>
Restart the web application server after these changes.
Selecting the configuration in a shared library of JNDI configurations
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.- 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.
- 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.
- 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
Alternatively, instead of editing the catalina.properties file, depending on the operating system, create or edit one of the following files:
- 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.
- On UNIX systems: $TOMCAT_HOME/bin/setenv.sh