Wednesday, 27 February 2013

Weblogic Server - Coherence Configuration Example


Weblogic Server - Coherence Configuration

For theoretical knowledge on coherence read my this post - http://weblogicserveradministration.blogspot.com/2011/05/oracle-coherence-37-coherenceweb.html

In this post I am going to cover practical example on Coherence

I have used Weblogic Server 10.3.5 + Coherence 3.6

High Level Steps

1.  Install weblogic server 10.3.5 with coherence 3.6 or 3.7
2.  Create a domain
3.  Create a machine, start node manager and check status from console if it's accessible
4.  Create a a simple cluster with two managed servers, and assign both managed servers to 
      machine
5.  Create a Coherence cluster and assign your above defined cluster to coherence cluster
      [ OR instead of above step2 and step3, you can just create two managed servers, then  
         create a coherence cluster and assign both managed servers to this coherence cluster ]
6.  Start a cache server
7.  Start both managed servers
8.  Deploy shared library files
9.  Create a testing application and deploy on cluster
10.Test 

Steps

1. For installation see my other post 
http://weblogicserveradministration.blogspot.com/2010/11/installation-ii-console-mode.html

2. For domain creation see my other post
http://weblogicserveradministration.blogspot.com/2012/12/weblogic-domain-creation-create.html
http://weblogicserveradministration.blogspot.com/2010/11/domain-creation-console-mode-dev.html
http://weblogicserveradministration.blogspot.com/2010/10/create-domain.html

3. For machine,node manager configuration see my other post
http://weblogicserveradministration.blogspot.com/2010/10/configure-start-stop-node-manager.html

4. To create a simple cluster and assign servers to cluster see my other post
http://weblogicserveradministration.blogspot.com/2010/10/vertical-clustering-step-by-step.html

5. Create a coherence cluster and assign your above created cluster to this coherence cluster

a. Login to admin console
b. Click on Coherence Clusters option on left hand side panel
c. Do the configuration like below and save

Unicast Listen Address - your machine hostname or i.p
Unicast Listen Post - 8085 ( or any other available port of your machine )
Multicat Listen Address - 231.1.1.1 ( or any multicast range available i.p but make sure this need to update in coherence server startup script which i will explain later )
Multicast Listen Port - 7777 ( or you can use any other available port of your machine but make sure this need to update in coherence server startup script which i will explain later )
























   











After creating coherence cluster, click on Target tab and assign your previously create simple cluster to this coherence cluster


































Now you can see like below under coherence cluster option










6. Start Cohrence Server

Copy the below contents, paste in a text file and rename it as .bat ( on windows )
( if you are on unix based systems then change scripts variable settings, path etc accordingly )

Start-Coherence.bat

setlocal

set COHERENCE_HOME=C:\Oracle\Middleware2\coherence_3.6
set COH_OPTS=%COH_OPTS% -server -cp %COHERENCE_HOME%\lib\coherence.jar;%COHERENCE_HOME%\lib\coherence-web-spi.war;
set COH_OPTS=%COH_OPTS% -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.cacheconfig=/WEB-INF/classes/session-cache-config.xml -Dtangosol.coherence.distributed.localstorage=true -Dtangosol.coherence.clusterport=7777 -Dtangosol.coherence.clusteraddress=231.1.1.1 -Dtangosol.coherence.session.localstorage=true
java %COH_OPTS% -Xms256m -Xmx256m -XX:MaxPermSize=256m com.tangosol.net.DefaultCacheServer
:exit

Now start above create script

Output should be like below

























7. Start both managed servers from console

8.  Deploy below shared libraries on your cluster ( During deployment make sure to choose 
     option deploy this file as library not application for both files )

 coherence-web-spi.war from  ORACLE_HOME\coherence_3.6\lib and  active-cache-1.0.jar  
  from  ORACLE_HOME\wlserver_10.3\common\deployable-libraries

9.  Create a testing application like below

[1] Create a folder CoherenceTest
[2] Inside CoherenceTest folder create 
      a. META-INF folder, Inside it a file with name manifest.mf with below contents


Extension-List: active-cache
active-cache-Extension-Name: active-cache
active-cache-Specification-Version: 1.0
active-cache-Implementation-Version: 1.0


 [3] WEB-INF folder
        
        3.1 inside it, create a file web.xml with below contents

               <?xml version = '1.0' encoding = 'windows-1252'?>
               <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web- 
               app_2_4.xsd" 
               xmlns="http://java.sun.com/xml/ns/j2ee" version="2.5">
              <description>Empty web.xml file for Web Application</description>       
             </web-app>
       
         3.2 inside it, create a file weblogic.xml with below contents

         <weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"  
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
         xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app 
         http://www.oracle.com/technology/weblogic/weblogic-web-app/1.1/weblogic-web-app.xsd">
         <library-ref>
           <library-name>coherence-web-spi</library-name>
         </library-ref>
         <coherence-cluster-ref>
            <coherence-cluster-name>CoherenceCluster</coherence-cluster-name>
         </coherence-cluster-ref> 
           </weblogic-web-app>

( Make sure here cluster name exactly the same you have given to your coherence cluster )

        3.3 inside it, create a folder with name lib and copy coherence.jar file from 
               COHERENCE_HOME\lib to here ( ORACLE_HOME\coherence_3.6\lib in my case )
        
 [4]. A jsp file with name counter.jsp ( copy and paste below code inside it )


<html>
    <body>
<h3>
      Counter :
      <%
         Integer counter = new Integer(1);
         HttpSession httpsession = request.getSession(true);
         if (httpsession.isNew()) {
                httpsession.setAttribute("count", counter);
                out.println(counter);
         } else {
                int count = ((Integer) httpsession.getAttribute("count")).intValue();
                httpsession.setAttribute("count", new Integer(++count));
                out.println(count);
         }
      %>
      </h3>

    </body>
</html>


Below is the structure




















10. Deploy this CoherenceTest application as in exploded form on your cluster

11. Test

Now, first access you application using first managed server URL

http://host:first_managed_server_port/CoherenceTest/counter.jsp

it will show you as counter : 1














After that access your application using second managed server URL

http://host:second_managed_server_port/CoherenceTest/counter.jsp

it will show you counter : 2












So, here session shared on your external coherence server and shared across servers on your cluster..

you are done...cheers!!!!!!!


Feel free to write me in case you have any issues or doubt....



Saturday, 23 February 2013

Weblogic Server Deployment


Weblogic Server Deployment

Deploy war file


Access admin console

http://admin_host:admin_port/console


Click on Lock & Edit button ( If have production mode domain )



















Click on "Deployment" option on your left hand side panel


























Click on "install" option on right hand side, and next

Browse you application and select next


Select option install this deployment as an application and select next


Select your target server or cluster and click next



Select all default options ( or select according to your need like change application name with more significant text, deployment modes etc )



Select finish option



Click on activate changes ( if your domain in production mode )



Click on deployment, check your application box, click on start > servicing all requests



your application will come in active state ( of course if there is no issues with your application :) )



now go ahead and access your application

In my case, below is the screen




Other Posts

Application Status
Packaging Files
Disable on demand deployment option
Deployment Forms - Archive & Exploded
Side by Side Deployment
Quick Deployment Using WLST
Make You Application as Default Application
Deployment As Library Option
Creating WAR File
Web Application ( WAR ) Basic Concepts
EAR File Directory Structure
Autodeployment
Partial Deployment Of Static Files