NexJ Logo

Deploying Model Server

You can deploy NexJ Model Server to a locally addressable location (somewhere on the network) or to a remote location. You can either use NexJ Studio or the command line to deploy.

When you deploy Model Server , a file is created for each node in the SERVER_HOME  directory. The file specifies the node name . By default, nodes are named node=<node1>, node=<node2>, ..., node=<nodeN> for deployments to multiple locations. You can change a node's value if you want to give the node a meaningful name, for example, report_server. Nodes require a unique name. For more information about NexJ-specific system properties, see Specifying JVM arguments and system properties .

Before you deploy Model Server, you must install any prerequisites as mentioned in Preparing the host machine.

Deploying through NexJ Studio

To deploy Model Server using NexJ Studio:

  1. In NexJ Studio, in the Deployment layer's Environment tab, open the environment file for the current deployment.
  2. In the Overview tab, ensure that Type is set to Generic.
  3. In the Deployment Location field, specify the folder directories or SSH folder directories for all the server nodes. For example, to deploy to two Model Server nodes, specify the directories as follows:

    Operating SystemNodesServersRemote/local deploymentExample
    Windows22Remote\\hostname1\nexj\modeld,\\hostname2\nexj\modeld
    21Remote

    \\hostname\nexj\modeld\{node1,node2}
    or
    \\hostname\nexj\modeld\node1,\\hostname\nexj\modeld\node2

    21Local

    D:\nexj\modeld\node1,D:\nexj\modeld\node2
    or
    D:\nexj\modeld\{node1,node2}

    Linux22Remotessh://hostname1/opt/nexj/modeld,ssh://hostname2/opt/nexj/modeld
    21Remote

    ssh://hostname/opt/nexj/modeld/{node1,node2}
    or
    ssh://hostname/opt/nexj/modeld/node1,ssh://hostname/opt/nexj/modeld/node2

    21Local

    /opt/nexj/modeld/node1,/opt/nexj/model/node2
    or
    /opt/nexj/modeld/{node1,node2}

    When running two or more nodes on the same server, ensure the port.offset property is specified so ports from different nodes do not conflict with each other. The default offset for the port is relative to the port in the HTTP server URL. For example, if the HTTP server URL is http://host.domain.ext:7080/nexj and the port offset is 100, the JVM will listen to port 7180 for HTTPS traffic.

    For more information about specifying system properties, see Specifying JVM arguments and system properties.

  4. If you are deploying a Model Server cluster, on the Clustering/Session tab, select the Distributed (Enable Clustering) checkbox.
  5. Save the updated environment file.
  6. If using SSH, do the following:
    1. Click  Window  >  Preferences . The  Preferences  dialog opens.
    2. Click  NexJ Studio  > Remote Deployment  >  SSH .
    3. In the  Known hosts file  field, enter the path to the known hosts file. The known hosts file allows  NexJ Studio  to authenticate the server.
    4. In the Personal key  field, do one of the following:
      1. If basic authentication is enabled in the environment file, select the  Use password from the .server file (basic authentication) .
      2. If basic authentication is not enabled in the environment file, in the  Identity file field, enter the path to the private key for the client.
  7. If you want to use environment variables from a properties file, click the Set current server button  and select the environment and properties file combination that you want to use. 
  8. Copy the appropriate database driver, such as jtds-1.2.2-9.jar or ojdbc14.jar, to your project's lib directory.
  9. Click the  Deploy Model  button . The server instance or cluster is installed in the directories that you specified. 

    In case the database driver that you copied in the previous step does not get deployed, be sure to copy the appropriate database driver, such as jtds-1.2.2-9.jar or ojdbc14.jar, to the < SERVER_HOME>\jvm directory for each deploy location that you specified earlier in the Deployment Location field. If you are using Java 8 or lower, you can, alternatively, add the database driver to the $JAVA_HOME/jre/lib/ext  folder .  If using SSH, tools such as sftp or scp may be required to copy the database driver. For more information about required database drivers, see Required database drivers in the NexJ CRM Release Notes.

The Model Server instance or cluster is deployed, and a BUILD SUCCESSFUL message displays in the Console.

The deploy directory contains the following directories:

DirectoryContains
binmodeld.bat, modeld-svc.bat, modeld.sh files
confjvm.conf, log4j.properties, modeld.conf files
data/<node>Persistent data in <node>
jvmFramework JAR files
logLog outputs
modelModel JAR files
tmpTemporary working files
win32-x6464-bit executable file
win32-x8632-bit executable file

Deploying using command line

You may also use the command line to deploy Model Server without the help of NexJ Studio. The command line is necessary if you cannot use NexJ Studio in the deployment environment, or if you require the deployment process to be automated with a script.

You need the following to use this method:

  • Apache Ant
  • Java Development Kit
  • Studio plugin folder (nexjstudio_version)
  • Published model file

Specify the location for these items in the command line. For the Studio plugin folder, either NexJ Studio should be installed or the plugin should be extracted on the hard drive. If NexJ Studio is installed, the plugin folder is located in the NEXJ_PLUGIN/version/plugins directory.

To deploy Model Server using the command line:

  1. Open your command line console.
  2. Enter the deployment command at the prompt. You can run Ant directly by specifying its location or you can change your directory to the bin folder and run the program from there. If you are deploying through SSH and the remote host is not already trusted, add the remote host to your known hosts file or include the following line as part of the deployment command. 

    -Dinstaller.cmd.jsch.knownHostsFile=\<trust-all\>

    The deployment process executes. Ongoing results are displayed in the console window until the deployment finishes or an error occurs. If there is an error, the console displays the problem before halting execution.

    Following is a sample command for SSH deployment.

    $ANT_HOME/bin/ant \ 
          -f $NEXJ_PLUGIN/build/build.xml \ 
          -Dplugin.dir=$NEXJ_PLUGIN \ 
          -Dpublish.dir=$MIXINS \ 
          -Dbase.jar=$JAR_FILE \ 
          -Dproject=".tmp" \ 
          -Dout.dir=$OUT_DIR \ 
          -Dserver.properties=$PROP_FILE \ 
          -Dbuild.jnlp=false \ 
          -Dcipher.master.url=$MASTER_PWD \ 
          -Declipse.dir=$ECLIPSE_DIR \ 
          -Dinstaller.cmd.jsch.knownHostsFile=\<trust-all\> \ 
    server.config server.deploy | tee $SCRIPT_DIR/../log/deploy.log

    The following table provides example values for the parameters in the example deployment command.

    PropertyDescriptionExample value
    NEXJ_PLUGINThe location where the NexJ Studio plugin is installed./releases/modeld/framework/extracted/plugins/com.nexjsystems.nexjstudio_133.41.0
    MIXINSThe directory containing the NexJ mixins./releases/modeld/mixins
    JAR_FILEThe location of the JAR file containing the base metadata./releases/modeld/model/nexj-meta-project-0.0.2.0-27.885.1307.160.52-36f840ea.jar
    OUT_DIRThe location of temporary files used during the deployment process./releases/modeld/tmp
    PROP_FILEThe file containing environment properties./data/nexj/releases/modeld/env/.properties
    MASTER_PWDThe location of the master file if using password encryption. For more information, see Setting up password encryption./security/master.pwd
    ECLIPSE_DIRThe location of your Eclipse installation./releases/modeld/eclipse


  3. If you are using an SSH key instead of an SSH username and password, you must also include the location of the SSH key (which could be a pem file) in the deployment command. The JVM argument for this would be:
    -Dinstaller.cmd.jsch.identityFile="<ssh_key_file_location>"
  4. Copy the appropriate database driver, such as jtds-1.2.2-9.jar or ojdbc14.jar, to the < SERVER_HOME>/jvm directory for each deploy location that you specified earlier in the Deployment Location field. Alternatively, you can add the database driver to your Java classpath, for example, $JAVA_HOME/jre/lib/ext For more information about required database drivers, see Required database drivers in the NexJ CRM Release Notes.

The Model Server instance or cluster is deployed, and a BUILD SUCCESSFUL message displays in the Console.

If you want to compile the code using JDK 11, before starting the server, you will need to set the java code executable in the build.properties file to Java 11, as shown in the following example:

javac.executable=C:/Java/jdk-11.0.2/bin/javac.exe

Specifying environment properties through a properties file

You can use a properties file to set your environment properties through variables. This removes the need to edit the environment file directly every time you modify a setting and is useful if you want to experiment with the property values For example, to use a different HTTP URL for unit testing and staging from that you use in production, you can create three separate properties files named  development.propertiesunittest.properties, and staging.properties, specify a different value for the httpURL property in each of these files, and set them all for use with the same environment file. 

In case of a conflict, properties specified through the jvm.conf and modeld.conf files override the top-level variables in the environment file. For more information about jvm.conf and modeld.conf, see Specifying JVM arguments and system properties .

To use a property file for a Model Server deployment:

  1. Create properties files as needed.

    You can create a properties file by creating a text file in your project folder and changing its extension to .properties or by opening the environment in the Deployment layer of NexJ Studio and selecting Add in drop-down on the top right corner of the environment overview.

  2. Specify property values in the property files in the following format:
    <propertyName>=<propertyValue>
    For example, callRecordsEnabled=true or cloneCount=1.
  3. Select the properties file you want to use for the deployment:
    • If using NexJ Studio, select the file from the Set current server dropdown.
    • If using the command line, specify the property file using the following command:
      -Dserver.properties=$<PROP_FILE> \

      where PROP_FILE is the name of the properties file you want to use for the environment, for example, staging.properties.
  4. In the  environment file, specify the property that needs to be pulled from the properties file in the following format:
    <propertyName>="${<propertyName2>}"
    where  propertyName  is the property name as mentioned in the environment file, and  propertyName2  is the name of the property in the properties file that should replace propertyName. For example, callRecordSetting="${callRecordsEnabled}". When you deploy,  callRecordsEnabled  is replaced by True based on the setting in the properties file.
  5. In the properties file, specify the environment file in the following format:
    config=<environmentFileName>.environment

    For example, development.environment.
  6. Click the Deploy Model  button  in NexJ Studio or issue the deployment command using the command line. The following is a sample command that uses a properties file:

    c:\apache-ant\bin\ant 
    -propertyfile "c:/work/core_deploy.properties" 
    -f "c:/work/plugins/com.nexjsystems.nexjstudio/build/build.xml" 
    server.config server.deploy

The server gets deployed with the mapped values from the selected properties file.