Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Developing Web Applications in a Clustered Environment Using WLST and Workshop

Developing Web Applications in a Clustered Environment Using WLST and Workshop

Step 2: Start
In this step you start the clustered domain, and then deploy the application to the cluster.

Starting the clustered domain
To start the cluster, you use a script called startcluster.py. Since starting servers with WLST utilizes the WLS Node Manager, first you start the node manager and connect to it. Then, you start the Admin Server, and connect to it. Finally, you start the cluster.

The following code is from the startcluster.py script:

# set the following values if your installation is different
bea_home='c:\wls9'
weblogic_home='c:\\wls9\\weblogic90'
# nmhome and domaindir are based on the above settings
nmhome = weblogic_home + '\\common\\nodemanager'
domaindir = bea_home + '\\user_projects\\domains\\' + sys.argv[2]
# Start the node manager process
startNodeManager(verbose='true', NodeManagerHome=nmhome)
#Connect to the node manager
nmConnect(domainName='myclusterdomain',domainDir=domaindir)
# Start the Admin Server
nmStart('AdminServer')
# Connect to the Admin Server
connect('weblogic','weblogic', sys.argv[1])
# Start the cluster comprising of ms1 and ms2
start(sys.argv[3],'Cluster')
exit()

To run the script, type:

wlst.cmd startcluster.py t3://localhost:9001
myclusterdomain wlsCluster

Deploying the application
To deploy the application, you use the script called deploy.py. Here I am assuming you use the demonstration application, helloApp, which is part of the wlst-scripts.zip download accompanying this tutorial (see the helloApp directory).

The key command in the deploy script is:

deploy(appName='workshop_cluster_deployment',path=sys.argv[2],
targets=sys.argv[3])

Note that since the WLST deploy command is an online command, the deploy script first connects to the Admin Server. The deploy.py script assumes you'll pass in the following information:

  • Path to the application
  • Target server or cluster
  • URL to run the application

The appName is hard-coded to workshop_cluster_deployment, to be consistent with Workshop (as you'll see later).

To run the script, type:

wlst.cmd deploy.py t3://localhost:9001 /wlst-workshop/helloApp
wlsCluster http://localhost:9101/helloApp/hello.html

Note that two other scripts are provided (stopserver.py and startserver.py), which stop and start one of the two managed servers. I'll use this to show failover in the second part of this tutorial.

At this point you've used WLST to start the cluster and deploy the application to the cluster. Let's now run it!

Step 3: Running the Application
Let's now look at running the application from the browser. The script in Step 2 will invoke the browser with the URL below, or alternatively you can click here: http://localhost:9101/helloApp/hello.html.

Voila! You should see the application. You can now type in your name, and then click on "Submit name." A JSP (called hello.jsp) will be invoked that will say hello to you and print session information, which you'll use later.

You can also go to: http://localhost:9102/helloApp/hello.html and see the same application running on the other managed server. Of course, this setup is not very useful in practice; what you really want is for client requests to be automatically load balanced across the two servers, thereby achieving better scalability. To do this, you need to introduce a load balancer to front end the HTTP requests. The Apache Web Server, with the WebLogic Apache plug-in, is one such load balancer.

Using Apache for Load Balancing
You'll first need to download and install the Apache Web server, and then install the Apache HTTP Server Plug-in. Note that the plug-in is not installed by default when you install WebLogic Server—you need to select Custom Install and select the plug-in check box.

You add the following snippet to the Apache http.conf configuration file, to configure the plug-in:

LoadModule weblogic_module    modules/mod_wl_20.so
<IfModule mod_weblogic.c>
WebLogicCluster localhost:9101,localhost:9102
MatchExpression /hello
</IfModule>

This tells the plug-in to look for URLs with the string /hello and to redirect such requests to the cluster, represented by localhost:9101 and localhost:9102. When both servers are available, the HTTP Server will load balance requests. When only one of the servers is available, all the traffic will be routed to that server.

Now bring up a browser and simply type:

http://localhost/helloApp/hello.html

The request will now go to the Apache HTTP Server (set up using the default Port 80), which then routes to one of the available managed servers. To see which managed server serviced the request, you can use the getstatus.py script. Note that if you are using WebLogic Server 9.1 you'll need to copy the supplied getstatus.py.91 script into getstatus.py, to account for runtime MBeans changes between the two releases. This script uses the runtime MBean InvocationTotalCount for the hello.jsp service on each managed server to report how many times the hello.jsp service was invoked. The output will look something like:

ms1 count: 1
ms2 count: 0

This tells you that ms1 serviced the request.

At this point, you have used WLST to create a fully functional clustered environment for testing the application. You can now iteratively make changes to the app, redeploy the app to the cluster and test. WLST and the scripts provided here do all the hard work, so you as a developer can focus on your application, and quite easily test in a clustered environment.

Let's take a look at these three steps again: create, start, run—this time, right from the BEA Workshop IDE. I'll primarily use JSP functionality in the example. Workshop provides a professional JSP source editor, code completion, custom tag library support, simultaneous two-way source and visual JSP editors, JSP 2.0 (including EL), JSTL, a graphical editor for TLDs, and a graphical editor for web.xml.

To get started, first you'll need to extract the workshop-scripts.zip into your Workshop workspace, under \.metadata\.plugins\org.eclipse.debug.core\.launches.

Now, you'll need to bring the helloApp application into Workshop. You can accomplish this by typing File->New->Web Application Project, and then selecting Existing Web Application. You'll then see a screen similar to that shown in Figure 1.

Figure 1: Bringing an existing application into Workshop


More Stories By Michael Meiner

Michael Meiner is an Engineering Director at Oracle Corporation. His organization is responsible for lifecycle Quality Assurance of the Fusion Middleware Suite of products, including: installation, configuration, upgrade, test-to-production and interoperability on a range of computing platforms and Operating Systems. The Fusion Middleware product suite supports both On-Premise as well as Cloud offerings.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
Machine learning has taken residence at our cities' cores and now we can finally have "smart cities." Cities are a collection of buildings made to provide the structure and safety necessary for people to function, create and survive. Buildings are a pool of ever-changing performance data from large automated systems such as heating and cooling to the people that live and work within them. Through machine learning, buildings can optimize performance, reduce costs, and improve occupant comfort by ...
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Disruption, Innovation, Artificial Intelligence and Machine Learning, Leadership and Management hear these words all day every day... lofty goals but how do we make it real? Add to that, that simply put, people don't like change. But what if we could implement and utilize these enterprise tools in a fast and "Non-Disruptive" way, enabling us to glean insights about our business, identify and reduce exposure, risk and liability, and secure business continuity?
In this Women in Technology Power Panel at 15th Cloud Expo, moderated by Anne Plese, Senior Consultant, Cloud Product Marketing at Verizon Enterprise, Esmeralda Swartz, CMO at MetraTech; Evelyn de Souza, Data Privacy and Compliance Strategy Leader at Cisco Systems; Seema Jethani, Director of Product Management at Basho Technologies; Victoria Livschitz, CEO of Qubell Inc.; Anne Hungate, Senior Director of Software Quality at DIRECTV, discussed what path they took to find their spot within the tec...
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
DXWorldEXPO LLC announced today that Telecom Reseller has been named "Media Sponsor" of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.