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
# 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
# Start the Admin Server
# Connect to the Admin Server
connect('weblogic','weblogic', sys.argv[1])
# Start the cluster comprising of ms1 and ms2

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:


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

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:


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
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.
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things'). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing. IoT is not about the devices, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...