Configuring a MobileFirst project in production by using JNDI environment entries
When you deploy a MobileFirst project to MobileFirst Server, you can configure the project WAR file with JNDI environment entries to set product environment properties.
About this task
JNDI environment entries cover all the properties that you can set in a production environment. For details about the JNDI entries, see JNDI environment entries for MobileFirst projects in production.
Procedure
Set the JNDI environment entries in one of the following ways:
- Edit the configuration XML file for the deployer Ant tasks.
When you deploy and configure the project with the Ant task, you can set values for MobileFirst configuration properties inside the <configureapplicationserver> tag. For more information, see Deploying a project WAR file and configuring the application server with Ant tasks
For example:<configureapplicationserver shortcutsDir="${shortcuts.dir}"> <property name="serverSessionTimeout" value="30"/> <property name="publicWorkLightHostname" value="www.example.com"/> <property name="publicWorkLightPort" value="80"/> <property name="publicWorkLightProtocol" value="http"/>
- Configure the server environment entries. The
steps to configure the server environment entries depends on which
application server you use.
- WebSphere® Application Server:
- In the administration console, go to Applications > Application Types > WebSphere enterprise applications > Worklight > Environment entries for Web modules
- In the Value fields, enter values that
are appropriate to your server environment. See Figure 1. Figure 1. Setting JNDI environment entries on WebSphere Application Server
- WebSphere Application Server Liberty profile:
Insert the following declarations in the server.xml file:
<application id="worklight" name="worklight" location="worklight.war" type="war" context-root="/app_context_path"> </application> <jndiEntry value="9080" jndiName="app_context_path/publicWorkLightPort"/> <jndiEntry value="www.example.com" jndiName="app_context_path/publicWorkLightHostname"/>
The context path (in the previous example: app_context_path) connects between the JNDI entry and a specific MobileFirst application. If multiple MobileFirst applications exist on the same server, you can define specific JNDI entries for each application by using the context path prefix. Typically, app_context_path is "worklight".
- Apache Tomcat:
Insert the following declarations in the server.xml file:
<Context docBase="app_context_path" path="/app_context_path"> <Environment name="publicWorkLightPort" override="false" type="java.lang.String" value="9080"/> <Environment name="publicWorkLightHostname" override="false" type="java.lang.String" value="www.example.com"/> </Context>
Note: On Apache Tomcat, override="false" is mandatory.With Apache Tomcat, the context path prefix is not needed because the JNDI entries are defined inside the <Context> element of an application.
Preconfiguring JNDI properties:As an alternative to setting JNDI environment entries when you deploy a MobileFirst project to MobileFirst Server, you can configure all JNDI properties before you deploy by using a property file. Holding JNDI properties in a property file makes it easier to transfer the entire configuration from one web application server to another. For example, you can configure a test web server; when the configuration is stable, you can easily transfer the configuration to the production web server by copying the property file to the production server. For more information, see Predefining MobileFirst Server configuration for several deployment environments.
In some cases, when you do not want to or cannot redeploy the application, you can set values for MobileFirst configuration properties manually on the server configuration files (or console). This procedure is what the Ant task does behind the scenes. The manual configuration method is less recommended because in some cases (for example, when you upgrade or redeploy), the application server might forget the configuration and the administrator must reconfigure it.
Tip: If you choose to configure manually, be aware that if the application is upgraded or redeployed, your settings might be overwritten and then the administrator would then have to reconfigure the properties. - WebSphere® Application Server: