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
Use these steps to deploy through NexJ Studio using only an environment file to specify the relevant values. If you want to use environment variables from a properties file, follow the instructions in Specifying environment properties through a properties file.
To deploy Model Server using NexJ Studio:
In NexJ Studio, in the Deployment layer's Environment tab, open the environment file for the current deployment.
In the Overview tab, ensure that Type is set to Generic.
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 System
Nodes
Servers
Remote/local deployment
Example
Windows
2
2
Remote
\\hostname1\nexj\modeld,\\hostname2\nexj\modeld
2
1
Remote
\\hostname\nexj\modeld\{node1,node2} or \\hostname\nexj\modeld\node1,\\hostname\nexj\modeld\node2
2
1
Local
D:\nexj\modeld\node1,D:\nexj\modeld\node2 or D:\nexj\modeld\{node1,node2}
ssh://hostname/opt/nexj/modeld/{node1,node2} or ssh://hostname/opt/nexj/modeld/node1,ssh://hostname/opt/nexj/modeld/node2
2
1
Local
/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.
In theKnown hosts filefield, enter the path to the known hosts file. The known hosts file allowsNexJ Studioto authenticate the server.
In thePersonal keyfield, do one of the following:
If basic authentication is enabled in the environment file, select theUse password from the .server file (basic authentication).
If basic authentication is not enabled in the environment file, in theIdentity filefield, enter the path to the private key for the client.
Copy the appropriate database driver, such as jtds-1.2.2-9.jar or ojdbc14.jar, to your project's lib directory.
Click theDeploy Modelbutton . 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:
Directory
Contains
bin
modeld.bat, modeld-svc.bat, modeld.sh files
conf
jvm.conf, log4j.properties, modeld.conf files
data/<node>
Persistent data in <node>
jvm
Framework JAR files
log
Log outputs
model
Model JAR files
tmp
Temporary working files
win32-x64
64-bit executable file
win32-x86
32-bit executable file
Deploying using command line
Use these steps to deploy through the command line using only an environment file to specify the relevant values. If you want to use environment variables from a properties file, follow the instructions in Specifying environment properties through a properties file.
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:
Open your command line console.
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.
CODE
-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.
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>"
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.properties, unittest.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:
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.
Specify property values in the property files in the following format: <propertyName>=<propertyValue> For example, callRecordsEnabled=true or cloneCount=1.
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> \ wherePROP_FILEis the name of the properties file you want to use for the environment, for example, staging.properties.
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.
In the properties file, specify the environment file in the following format: config=<environmentFileName>.environment For example, specify config=development.environment.
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: