WebLogic Basics

12
0
Send lab feedback

WebLogic Basic Lab

About WebLogic Server

Oracle WebLogic Server is a unified and extensible platform for developing, deploying and running enterprise applications, such as Java, for on-premise and in the cloud. WebLogic Server offers a robust, mature, and scalable implementation of Java Enterprise Edition(EE) and Jakarta EE.

To Know more about Oracle WebLogic Server. Please click the following link Oracle-WebLogic-Server .

Using the Oracle WebLogic Server domain image, we can have two types of containers:

  1. Admin Server container with a single Oracle WebLogic Server Admin Server
  2. Managed Server container

These Docker containers enable users to create clustered and non-clustered Oracle WebLogic Server domain configurations. Each server running in the domain runs in its own Docker container and is capable of communicating as required with other servers on the same host.

In the sample-domain1, we have a Dynamic cluster cluster-1 which has 5 managed server configured. In this Lab, using docker run we will run one Admin Server container and one Managed Server container.

We have the following advantages of this topology.

  • Good for traditional-like deployments.
  • Easy to deploy containers from Oracle WebLogic Server domain images.
  • Easy to scale up and down the cluster.
  • Good for developers.
  • No need to install or configure anything on host except for Docker binaries.

Connectivity to Database

In WebLogic Server, you can configure database connectivity through JDBC datasource, either in your WebLogic domain configuration or in your enterprise application. A datasource is a Java EE standard method of configuring connectivity to a database. Each WebLogic data source contains a pool of database connections.

Applications look up the datasource on the JNDI tree or in the local application context and then use a database connection from the pool of connections. Data sources and their connection pools provide connection management processes that help keep your system running efficiently.

WebLogic communicates with the database through a connection pool. The connection pool enables WebLogic to use a fixed number of connections to databases rather than incur the overhead of constantly creating and disposing of connections.

Running and deploying JavaEE applications on WebLogic

WebLogic Server implements the Java EE 7 specification. Java EE 7 includes a deployment specification, JSR-88, that describes a standard API used by deployment tools and application server providers to configure and deploy applications to an application server.

The WebLogic Server configuration generated by a Java EE deployment API configuration process is stored in a deployment plan and one or more generated WebLogic Server deployment descriptor files as shown in below images

Running WebLogic Server in Docker

This lab uses the Docker image with WebLogic domain inside the image deployment. We do it as this is the easiest way nowadays to provision lab environments and provision WebLogic in testing and development environments. We avoid process of installing Java, WebLogic Server binaries and configuring the domain. This means that all the artifacts and domain-related files are stored within the image.

WebLogic-Remote-Console

During these labs we will be using the latest WebLogic Server console that runs outside of the context of the Admin Server. It will run on the desktop of the Administrator. It is called WebLogic Remote Console and it is a lightweight, open-source console that you can use to manage your WebLogic Server domain running anywhere, such as on a physical or virtual machine, in a container, Kubernetes, or in the Oracle Cloud. The Remote Console does not need to be co-located with the WebLogic Server domain.

You can install and run the Remote Console anywhere, and connect to your domain using WebLogic REST APIs. You simply launch the desktop application and connect to the Administration Server of your domain. Or, you can start the console server, launch the console in a browser and then connect to the Administration Server.

The Remote Console is fully supported with WebLogic Server 12.2.1.3, 12.2.1.4, and 14.1.1.

Key Features of the WebLogic Remote Console

The WebLogic Remote Console provides an alternative WebLogic Server administration GUI that enables REST-based access to WebLogic management information, in alignment with current cloud-native trends. When connected to a WebLogic domain using the Remote Console, you can:

  • Configure WebLogic Server instances
  • Configure WebLogic Server clusters
  • Configure WebLogic Server services, such as database connectivity (JDBC), and messaging (JMS)
  • Deploy and Un-deploy applications
  • Start and stop servers and applications
  • Monitor server and application performance
  • View server and domain log files
  • View application deployment descriptors
  • Edit selected runtime application deployment descriptor elements

Difference with the WebLogic Server Administration Console

If you are already familiar with the WebLogic Server Administration Console deployed as part of your WebLogic domain, you'll notice these key differences in the WebLogic Remote Console:

  • The user interface has been completely redesigned to conform to the Oracle Alta UI Design system and the Oracle Redwood theme included with Oracle JET.
  • The configuration and monitoring content is separated into separate pages in the Remote Console. In the WebLogic Server Administration Console, the configuration and runtime information are presented on one page. See Separation of Configuration and Runtime Data .
  • The Change Center is now expressed as a shopping cart. See Use the Shopping Cart .
  • Instead of logging directly into the Administration Console deployed in a WebLogic domain, the Remote Console connects to the Administration Server in a WebLogic domain, with the credentials supplied by the user, using WebLogic REST APIs.

Lab scenario

You will:

  • Start Admin and Managed servers (as docker containers)
  • Verify that those two are up and running by connecting to WebLogic Admin Console
  • Create JDBC Connection Pool and establish connection between WebLogic and Oracle database
  • Deploy sample application and verify that it is up and running
  • Setup WebLogic Remote Console
  • Make a configuration change using the remote console and monitoring the progress

STEP 1: Navigating to the Resource

In this step you will deploy the WebLogic docker image on the compute instance already provided for you.

You will connect to the compute instance (VM) via Terminal and pull the Docker image that contains the binaries of WebLogic and some sample domain configuration. Then you will start Admin Server and login to WebLogic console to verify is up and running.

  1. Let’s navigate through to the resources, which is provisioned for you as part of this Lab.

    Start by login to your OCI Console.

    Open the Luna-Lab.html file located in the desktop. Here you will find the login tenant information required for this lab.

    Click the the OCI CONSOLE button to logon.

    Log in with the credentials provided.

  2. Click the Hamburger menu on the left upper corner, then click Compute -> Instances.

  3. In the Compartment, Select the compartment which is under the Luna-Labs as shown below.

  4. You can see the Instance in this section, which we will use in this lab. Click the Instance.

  5. This page contains the details about this Instance, find the PUBLIC_IP address of your instance and copy it. The next step will require the PUBLIC_IP address as we will connect to the instance via a terminal.


You can continue with the next step.


STEP 2: Starting Admin Server in Docker Container

In this step you will connect to the VM (through SSH) and download or pull the image that contains the binaries of WebLogic and some sample domain configuration.

Then you will start Admin Server from the sample WebLogic domain and login to verify that the Admin server is up and running.

  1. Open a Terminal Emulator from the main desktop applications menu. Right-click Luna Desktop and click Open Terminal Here.

  2. From the terminal window enter the following SSH command. Replace PUBLIC_IP address.

    You can paste the command by right click anywhere on the terminal window and select Paste.

    ssh -i ~/.ssh/id_rsa opc@PUBLIC_IP

    Example

    ssh -i ~/.ssh/id_rsa

    opc@193.122.156.83
    https://luna.oracle.com/api/v1/labs/77b25364-204a-4ed0-9dc8-6e993fe1e659/gitlab/javascript:void(0)

    The -i switch is where you designate the name of the public key (.pub) and following that is the IP address of your compute instance prefaced by the default admin user name, opc and the @ sign.

    Answer yes to the prompt about accepting the identity and adding to the list of known hosts.

    You have successfully login to your server instance as user opc. Do not close the window, you will need to use it again later on the lab.

  3. Start WebLogic Admin Server inside Docker. The Docker image with the sample domain is stored in OCIR registry (registry in Oracle Cloud).

    Execute the following command to deploy the WebLogic docker image.

    sudo docker run -p 7001:7001 --network='bridge' --name='WLSADMIN' --rm iad.ocir.io/weblogick8s/weblogic-operator-tutorial-store:1.0 /u01/oracle/user_projects/domains/sample-domain1/bin/startWebLogic.sh

    The server will open inside the container port 7001. And this port will be mapped to port 7001 of the VM. So the admin server will be accessible through port 7001 of our VM.

    You will get the message that no locally stored image available.

    It will then download the image.

    Check the server is RUNNING. Do not close the Terminal window, you will need it later in this lab.

    Note

    This docker command initially search for the image locally. If not found, it downloads (pulls) the image from the Oracle Public Repository.

    This image has WebLogic Domain embedded in it. Once that is done, it will start the admin server in a container on port number 7001, and map this port to 7001 on the host machine.

  4. Lets have a look at the WebLogic Admin Console and confirm it has started successfully. Go to your browser and enter in this URL, replacing the PUBLIC_IP address.

    URL:

    http://PUBLIC_IP:7001/console

    Example

    http://193.122.156.83:7001/console

    The WebLogic server started successfully.

  5. Login using the following credentials.

    Username:

    weblogic

    Password:

    welcome1
  6. Verify the configuration of the domain and verify that the Admin Server is properly up and running.

    To do this, scroll down then click Environment-> Servers and check that all the Managed servers are in SHUTDOWN state and Admin Server is in the RUNNING state.


You have logged in to an OCI compute instance and successfully deployed a WebLogic Admin Server.

You can continue with the next step.


Step 3: Starting a Managed Server in Docker Container

In this step you will start another Docker container that will run one of the configured Managed Servers. You will deploy the Managed Server on the same VM as the Admin Server, this time on port 8001.

  1. Start Managed Server as Docker container.

    Using the same image from the previous step, you will start another process within that Docker container (this time on a Managed Server instead of the Admin Server).

    While leaving open the Terminal window you used earlier, create a new Terminal window.

    Use the same command from earlier to SSH into your instance.

    ssh -i ~/.ssh/id_rsa opc@PUBLIC_IP

    Then enter the following command to deploy the Managed Server, replacing the PUBLIC_IP address.

    sudo docker run -p 8001:8001 --network='bridge' --name='WLSMS1' --rm iad.ocir.io/weblogick8s/weblogic-operator-tutorial-store:1.0 /u01/oracle/user_projects/domains/sample-domain1/bin/startManagedWebLogic.sh managed-server1 t3://PUBLIC_IP:7001 -Dweblogic.management.username=weblogic -Dweblogic.management.password=welcome1

    Check the logs that the listener is on port 8001 and that the server is running.

    Note

    The image is already downloaded in local repositories, it starts the managed-server1 on port number 8001 in the container. You need to authenticate while connecting to admin server.

  2. Check the managed server status in the WebLogic console.

    In the web browser, go to the WebLogic console tab, press button F5 to refresh the screen.


You have deployed and started a managed server.

You can continue with the next step.


Step 4: Creating JDBC Data-Source through Admin Console

In this step you will learn how to configure a DataSource object in WebLogic Server so your applications can interact with the Connection Pool mechanism and connect to an appropriate DataSource.

WebLogic Server connects to Database(s) through a mechanism called connection pooling. So, the application server opens a set of pre-defined connections that can be reused by the applications.

When an application requires a connection, it uses the API to find an appropriate Connection Pool (the API is called DataSource API) and asks to "borrow" a connection for a moment. It is the application'd responsibility to "return" the connection to the pool once the connection is no longer needed.

In this environment you will find an Oracle DB instance already created for you.

  1. Obtain the database connection details.

    On OCI main page, click Hamburger menu in upper left corner, then click Oracle Database -> Bare Metal, VM and Exadata.

  2. Select the Compartment.

  3. On the Databases system table, click the database system name provided.

  4. Scroll down the page and on the Database table select the database provided. It should have a database unique name next to it.

  5. Obtain the Database IP address and the service name.

    To do this, click DB Connection button, then click Show in Long format.

    Example

    10.0.0.159 and wldb_yyz145.wldomain

    You will create JDBC data source using the IP address in the next step.

  6. In your web browser, open the tab for WebLogic Admin Console. We will now create the Data Source.

    Click the Lock & Edit button.

    Click Services-> Data Sources on the left sidebar. Then hit the drop-down button New and click the option Generic Data Source.

    Enter the Following Details and click Next.

    ParameterValue
    NametestDS
    ScopeGlobal
    JNDI Namejdbc/testDS (Name used to find Connection Pool)
    Database TypeOracle

  7. In the next screen, leave the Database Driver as “Oracle Driver (Thin) for Service Connection; Version: Any” and click the Next button.

  8. Leave the default values and click the Next button.

  9. Enter the following details, then hit next.

    ParameterValue
    Database nameUse the service name obtained from the previous step
    Host nameUse the IP address obtained from the previous step
    Port1521
    Database User Namesystem
    PasswordAAaa11##1

    Note

    Leave oracle.jdbc.DRCPConnectionClass blank.

  10. Test the configuration.

    Click the Test Configuration button.

    Check connection is successful.

    Click the next button to continue.

  11. Select ‘admin-server’ as the target and click the Finish button.

  12. Activate the changes.

    Click “Activate Changes”. This will end the "Edit" session and apply the changes you've made.

    The changes have been activated successfully.

  13. In this WebLogic image, there is a pre-configured web application that is running on the Managed Server.

    This pre-configured web app allows you to test and verify all JDBC Connection parameters from a DataSource.

    Click Deployments.

    The application testwebapp deployed in cluster.

  14. Run the application in a browser.

    Go back to your web browser and enter the following URL in a new tab, remember to replace the PUBLIC_IP address.

    The managed-server1 is running at port number 8001, the context for the application is ‘/opdemo’, and the Datasource name is ‘testDS’.

    http://PUBLIC_IP:8001/opdemo/?dsname=testDS

    Example

    http://243.13.12.12:8001/opdemo/?dsname=testDS

    This application displays the Datasource properties Datasource name, Database URL and Database User.


You can continue with the next step.


Step 5: Deployment of Application on Managed Server

In this step you will deploy the application aussie-tripper-v1.ear to a dynamic cluster.

  1. Download the application aussie-tripper-v1.ear.

    Leaving the previous Terminal windows open, create a new Terminal window. Enter the following command.

    curl -LSs https://github.com/pandey-ankit/WebLogic-Basic-Lab/blob/main/aussie-tripper-v1.ear?raw=true > ~/Desktop/aussie-tripper-v1.ear

    Note

    This command downloads the application aussie-tripper-v1.ear from a git repository and put it in Desktop.

  2. Upload and deploy the application in WebLogic

    In your browser, go to the admin console tab and click Deployments.

    Click Lock & Edit to enter edit mode.

    Click Install.

    Click “Upload your file(s)”.

    Within Deployment Archive, click Choose File.

    Select the aussie-tripper-v1.ear file in the /home/luna.user/Desktop folder and click Open.

    Check that the correct file is selected and click Next.

    Select the aussie-tripper-v1.ear file and click Next.

    Select Install this deployment as an application and then click Next.

    Select “cluster-1” from available targets for aussie-tripper-v1 and then click Next.

    Keeping the default values click Finish to exit the install application assistant.

  3. To activate the changes and leave edit mode, click “Activate Changes” in the Change Center window.

  4. Start the new service you just installed.

    Select the Control tab, check the box for the aussie-tripper-v1 application and click Start -> Servicing all request.

    Click Yes.

  5. Lets have a look at the application in the web browser.

    Open a new tab in your Browser and open the following URL replacing the PUBLIC_IP address.

    http://PUBLIC_IP:8001/aussie-tripper

    Example

    http://243.13.12.12:8001/aussie-tripper

    Try out the application before moving on to the next task.


You can continue with the next step.


Step 6: Accessing Admin Server using WebLogic-Remote-Console

In this step, you will learn how to run the Remote-Console on a local browser and how to connect to the WebLogic server you have deployed.

  1. Download the console zip file to the local folder.

    Copy the following URL to a new tab on your browser.

    https://github.com/oracle/weblogic-remote-console/releases

    Click the file name console.zip.

  2. Start the remote console service on your local machine.

    In the most recently opened terminal, navigate to the Downloads folder.

    cd ~/Downloads/

    Extract the zip file you just downloaded.

    unzip console.zip

    Start the console service.

    java -jar console/console.jar

    The WebLogic Remote Console has started once the log indicates server started.

  3. Login to the WebLogic Remote Console.

    In the web browser (must be within Luna), enter this URL.

    http://localhost:8012

    The WebLogic Remote Console works directly on the desktop of Luna (not in the VM) using localhost and the default port, 8012.

  4. Connect to the WebLogic Admin Server running on your VM.

    Enter the Following details replacing the PUBLIC_IP address and click Connect .

    Username:

    weblogic

    Password:

    welcome1

    URL:

    http://PUBLIC_IP:7001


You can continue with the next step.


Step 7: Re-Configuration of JDBC Datasource through WebLogic-Remote-Console

In this step, you will use the WebLogic-Remote-Console to make configuration changes to the JDBC datasource testDS, changing the minimum capacity from 1 to 2.

With WebLogic Admin console, when you make changes, you need to click activate for the changes to be effective. However, in WebLogic-Remote-Console you click Save, which makes an entry in the Shopping Cart, and then click Commit Changes to make the changes effective.

  1. After we connect to Admin Server, we can see two options: Configuration and Monitoring.

  2. Click the configuration icon, then hit Services-> JDBC System Resources-> testDS as shown in the image below. On the page, click the Connection Pool tab.

  3. Click the Hamburger menu in the upper left corner to minimize the sidebar and then press F11 to enter full screen. This will make is easier to navigate the page.

  4. Change both the Initial Capacity and Minimum Capacity from 1 to 2 in Connection Pool tab and then click Save.

  5. It shows “Changes added to the cart”.

  6. Click the shopping cart icon and then click Commit Changes.

  7. Go to Admin Console http://PUBLIC_IP:7001/console and verify the changes we made through the WebLogic-Remote-Console.

  8. Click Services-> Data Sources, find testDS in the table, then click the Connection Pool tab.

  9. Verify that Initial Capacity and Minimum Capacity are both set to 2.


You can continue with the next step.


Step 8: Monitoring through WebLogic-Remote-Console

In this step, you will learn how you can monitor the Open Session Count for an application through WebLogic-Remote-Console. By using the incognito windows feature in the Chrome browser, you can simulate multiple open sessions.

  1. In the browser, go to the WebLogic-Remote-Console tab and navigate to the component runtime for the application.

    Click the monitoring icon and navigate through Running Servers -> managed-server1 -> Deployments -> Application Runtimes -> aussie-tripper-v1_v1 -> Component Runtimes -> managed-server1/aussie-tripper.

    Note

    The Session Opened Total Count is equal to 1 assuming you did not close your earlier aussie-tripper tab.

  2. Go to the Chrome browser settings menu and select a New Incognito window.

  3. To open the application, enter the following URL in the browser replacing the PUBLIC_IP address.

    http://PUBLIC_IP:8001/aussie-tripper

    Example

    http://243.13.12.12:8001/aussie-tripper

  4. Go back to WebLogic-Remote-Console and click the Refresh icon.

  5. Verify that the open session count shows 2.


Congratulations!

You have successfully completed this lab.

To end this session, click the End Session button in the toolbar.


SSR