+

Search Tips   |   Advanced Search

Use a shared library of JNDI properties

We can create a shared library to hold different configurations for any MobileFirst Server component.

If we do not want to inject properties into web archive files, the property file can be installed as a shared library for all MobileFirst Server components. This approach is useful when you intend to exchange the web archive files often, but want to keep the same configuration all the time. The original web archive files remain unchanged, but we need to install an additional shared library.

We 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.


Creating a shared library of JNDI properties

The wljndiinject command line tool is used to create a shared library for a set of property files. To create a shared library named jndiprops.jar with the property files testconf.properties and prodconf.properties, use the following command:

Options of the tool:

--help

Shows the help.

--sourceWarFile file

This option is not required for creating a shared library. This option is used when a property file is injected into a web archive file to identify the web archive file.

--destFile file

The destination file name of the shared library.

--sharedJar

Used to create a shared library instead of injecting a property file into a web archive file.


Install a shared library of JNDI configurations

Assume that all web applications are already installed. The shared library is added to the web applications.

WAS full profile

Determine a suitable directory for the shared library jndiprops.jar in the WAS installation directory and place the jndiprops.jar file there.

  • For a stand-alone server:

    $WAS_INSTALL/optionalLibraries/IBM/Worklight

  • For deployment to a dmgr cell:

    $WAS_INSTALL/profiles/myprofile/config/cells/mycell/Worklight

  • For deployment to a dmgr cluster, use:

    $WAS_INSTALL/profiles/myprofile/config/cells/mycell/clusters/cluster-name/Worklight

  • For deployment to a dmgr node, use:

    $WAS_INSTALL/profiles/myprofile/config/cells/mycell/nodes/node-name/Worklight

  • For deployment to a dmgr server, use:

    $WAS_INSTALL/profiles/myprofile/config/cells/mycell/nodes/node-name/servers/server-name/Worklight

For details about adding the shared library, see Add the shared library (WAS full profile).

WAS 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 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.


Select 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, 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.

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.

WAS Liberty profile

We 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

We 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.sh

    For example, add:

      CATALINA_OPTS="$CATALINA_OPTS -Dibm.worklight.jndi.configuration=testconf"

  • On Microsoft Windows systems: $TOMCAT_HOME/bin/setenv.bat

    For example, add:

      set CATALINA_OPTS=%CATALINA_OPTS% -Dibm.worklight.jndi.configuration=testconf

To enable the configuration, restart the web application server.


Parent topic: JNDI properties file for transfer