Deploying Applications for Java Sessions
Assuming your cache server IP is 20.200.20.40, the client.ncconf file should look as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<cache-server retry-interval="1" connection-retries="5" local-server-ip=" " port="9800" connection-timeout="5" client-request-timeout="90" retry-connection-delays="0"/>
<cache id="demoCache" default-readthru-provider=" " client-cache-id=" " load-balance="true" default-writethru-provider=" " client-cache-syncmode="optimistic">
<server name="20.200.20.40"/>
</cache>
</configuration>
Please follow the steps mentioned below to deploy an application on the server.
Apache Tomcat
For Tomcat 9, use J2EE and add the following Maven <dependency
> in the pom.xml
file.
<dependency>
<groupId>com.alachisoft.ncache</groupId>
<artifactId>ncache-javax-sessions</artifactId>
<version>x.x.x</version>
</dependency>
For Tomcat 10+, use Jakarta and add the following Maven <dependency
> in the pom.xml
file.
<dependency>
<groupId>com.alachisoft.ncache</groupId>
<artifactId>ncache-sessions</artifactId>
<version>x.x.x</version>
</dependency>
Note
To use Maven packages for the NCache Professional, change the <artifactId>
:
<artifactId>ncache-professional-sessions</artifactId>
The steps remain the same but the location of the files might change depending upon the Tomcat version. %TOMCAT_HOME%
refers to the location where Tomcat is installed.
Open the command prompt, and change the directory to
%TOMCAT_HOME%/bin
.NCache uses
log4j
for logging. Placelog4j
at%TOMCAT_HOME%/lib
.Create a new text document with the following contents and save it with the name of log4j.properties in the
%TOMCAT_HOME%/lib
folder.
log4j.rootLogger=DEBUG, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
Open the command prompt, change the directory to
%TOMCAT_HOME%/bin
, and execute the startup.bat file. This will start the server.Move the GuessGame.war file to the directory
%TOMCAT_HOME%/webapps
.Open a web browser and try to access http://host:port/GuessGame/index.jsp, where the host will be the address/IP of the machine where Tomcat is installed (in the case of the local machine it should be localhost) and the port where Tomcat is listening to the request. The default port for Tomcat is 8080.
WildFly
%WILDFLY_HOME%
refers to the location where WildFly is installed.
NCache uses
log4j
for logging. WildFly by default useslog4j
for logging so no need to move it.Deploy the GuessGame.war file, it must be copied into the correct directory so WildFly can find it. Then move the file to the directory
%WILDFLY_HOME%/server/default/delpoy
or you can also directly deploy from the WildFly admin console.Open a web browser and try to access http://host:port/GuessGame/index.jsp, where the host will be the address/IP of the machine where WildFly is installed (in case of the local machine it should be the localhost) and the port where WildFly is listening for the request. The default port for WildFly is 8080.
WebLogic
%WEBLOGIC_HOME%
refers to the location where WebLogic is installed. %DOMAIN_NAME%
is the already created domain on the server.
NCache uses
log4j
for logging. Place thelog4j
at the following location:%WEBLOGIC_HOME%/user_projects/domains/%DOMAIN_NAME%/lib
and restart the server.Move the GuessGame.war file to the directory
%WEBLOGIC_HOME%/user_projects/domains/%DOMAIN_NAME%/autodeploy
.Open a web browser and try to access http://host:port/GuessGame/index.jsp, where the host will be the address/IP of the machine where the WebLogic is installed (in case of the local machine it should be the localhost) and the port where the WebLogic is listening to the request. The default port for WebLogic is 7001.
WebSphere
%WEBSPHERE_HOME%
refers to the location where the WebSphere is installed.
NCache uses
log4j
for logging. Place thelog4j
at the following location and restart the server:%WEBSPHERE_HOME%/AppServer/lib/ext
.If WebSphere is installed properly, you will be able to access the admin console through a browser with the help of http://ip-address:port/ibm/console/
By default, 9060 is the port used by WAS. Make sure that you are using the correct port if you changed it during installation.
You can go to Applications -> New Application -> New Enterprise Application.
Specify the path of the GuessGame.war file and click Next. You can locate the GuessGame.war at the following location:
%NC_HOME%/samples/sessions/dist
.Select Fast Path installation mode and click Next.
Specify the Application Name and Application Directory both as GuessGame and click Next.
Map the application to the server, select GuessGame.war from the list with the default settings and click Next.
Map the application to the virtual host, Select GuessGame.war from the list with the default settings, and click Next.
Map the context root to the application, type 'GuessGame' into the textbox resulting in '/GuessGame' as the contents of the textbox and click Next.
Click Finish to complete the deployment.
Go to Applications -> Application Types -> WebSphere Enterprise Applications.
You should see the GuessGame application in the list, select the GuessGame application by clicking on the checkbox.
Click Start at the top left. You should see a green icon indicating that the application has started.
Open a web browser and try to access http://host:port/GuessGame/index.jsp, where the host will be the address/IP of the machine where the WebSphere is installed (in case of the local machine it should be the localhost) and the port where the WebSphere is listening for the request. Make sure that you are using the correct port. The default port for WebSphere is 9080.
See Also
Adding Libraries
Multi-site Java Session Support
Error Logging