Wednesday, April 3, 2013

Maven Deploy to Oracle Weblogic. Step By Step. The Basics. Part 2/4

This is a series of  four (4) articles that will describe how to use Maven and deploy a sample application to Weblogic.

Contents of each part:

There are no assumptions here and we are going to do everything from scratch.

There is always a person out there that will have to use those technologies together without knowing any of them.

So far, we have learned about Maven, what it is, and what is it's role in this task of ours. We understand that we have to create a Mavnen project and by using Maven we wil deploy our sample applications to Weblogic. But we dont know what weblogic is and how do we use it..


What is Weblogic?? Well, Weblogic is a lot of things.. In our case, we are talking about Weblogic Server. So, what is Weblogic Server?
According to Oracle's web site ( content extracted from )

Oracle WebLogic Server 12c is the industry's best application server for building and deploying enterprise Java EE applications with support for new features for lowering cost of operations, improving performance, enhancing scalability and supporting the Oracle Applications portfolio.
Okay... so what is an application server??
According to TSS (content extracted from
an application server provides an environment where applications can run, no matter what the applications are or what they do.

Furthermore, the JAVA EE 6 tutorial says (content extracted from )


Container Services

Containers are the interface between a component and the low-level platform-specific functionality that supports the component. Before it can be executed, a web, enterprise bean, or application client component must be assembled into a Java EE module and deployed into its container.
The assembly process involves specifying container settings for each component in the Java EE application and for the Java EE application itself. Container settings customize the underlying support provided by the Java EE server, including such services as security, transaction management, Java Naming and Directory Interface (JNDI) API lookups, and remote connectivity. Here are some of the highlights.
  • The Java EE security model lets you configure a web component or enterprise bean so that system resources are accessed only by authorized users.
  • The Java EE transaction model lets you specify relationships among methods that make up a single transaction so that all methods in one transaction are treated as a single unit.
  • JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access these services.
  • The Java EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine.
Because the Java EE architecture provides configurable services, application components within the same Java EE application can behave differently based on where they are deployed. For example, an enterprise bean can have security settings that allow it a certain level of access to database data in one production environment and another level of database access in another production environment.
The container also manages nonconfigurable services, such as enterprise bean and servlet lifecycles, database connection resource pooling, data persistence, and access to the Java EE platform APIs (see Java EE 6 APIs).

Container Types

The deployment process installs Java EE application components in the Java EE containers as illustrated in Figure 1-5.

Figure 1-5 Java EE Server and Containers
Diagram of client-server communication showing servlets and web pages in the web tier and enterprise beans in the business tier.
  • Java EE server: The runtime portion of a Java EE product. A Java EE server provides EJB and web containers.
  • Enterprise JavaBeans (EJB) container: Manages the execution of enterprise beans for Java EE applications. Enterprise beans and their container run on the Java EE server.
  • Web container: Manages the execution of web pages, servlets, and some EJB components for Java EE applications. Web components and their container run on the Java EE server.
  • Application client container: Manages the execution of application client components. Application clients and their container run on the client.
  • Applet container: Manages the execution of applets. Consists of a web browser and Java Plug-in running on the client together.

 And in order to be fully covered ( content extracted from )

The WebLogic Server complete implementation of the Java EE 6.0 specification provides a standard set of APIs for creating distributed Java applications that can access a wide variety of services, such as databases, messaging services, and connections to external enterprise systems. End-user clients access these applications using Web browser clients or Java clients. It also supports the Spring Framework, a programming model for Java applications which provides an alternative to aspects of the Java EE model. See Programming Models.

So, in a nutshell, Weblogic Server, is a container for JEE applications. It holds our JEE applications and we can access them by making requests to it (Weblogic Server that is.)
All we have to do is to deploy our application to Weblogic!

This article is not going to fully explain the architecture of Weblogic and it certainly does not itend to cover every aspect of it. Furthermore, it is not in the intention of this article to replace the official documentation. This article aims to introduce Weblogic to the reader and provide enough information and knowledge in order to finish the aforementioned task of deploying a sample application to weblogic using Maven.

Weblogic works with domains. What? yes. domains. What is a domain?
According to the official documentation ( content extracted from )
An Oracle WebLogic Server administration domain is a logically related group of Oracle WebLogic Server resources. Domains include a special Oracle WebLogic Server instance called the Administration Server, which is the central point from which you configure and manage all resources in the domain. Usually, you configure a domain to include additional Oracle WebLogic Server instances called Managed Servers. You deploy Web applications, EJBs, Web services, and other resources onto the Managed Servers and use the Administration Server for configuration and management purposes only.

And yes! you thought correct! We have to have a domain to deploy our JEE application.

Can we have more than one domain? YES! we can!
here is a very elaborative diagram from the official documentation (image copied from )

You see that you deside your structure and you deside how many domains you want. As simple as that. In our case, we only need on domain and no managed servers.

Getting Weblogic.

You can download Weblogic from the following link

Download your favorite version if you want. We will be using the latest  version at the time of this writting which is 12c (12.1.1). Since our example is rather basic, I dont think that you will face any issues with previous versions.

Installing Weblogic
The official documentation does an excellent job describing all the installation steps:
Without trying to copy paste the entire official documentation here xD I am extracting a sample of it as it seems to be the most common approach:
To start the installation program in graphical mode on a Windows platform, follow these steps.
  1. Log in to the Windows system.
  2. Go to the directory that contains the installation program.
  3. Double-click the installation file.
    For example, the name of the installation program for the WebLogic Server Package installer for Windows 32-bit is wls1036_win32.exe.
    The installation program begins to install the software.
See Installation Screens for a description of each installation program screen.

As you will see, it a pretty straightforward wizard that almost everything for you. All you have to do is define the jdk to be use and the Middleware home.

Note down the middleware home path! ( we will need it in later parts of this article )
(this image was taken from the official documentation.)

Once Weblogic is installed, we have to create a domain.

Creating a domain
Usually, when you are finished with the weblogic installation a new dialog is shown asking you if you want to configure your weblogic among other options. Even if you chose to close that window, you can still create a domain. Just follow the official instructions (content copied from )

  • To start the Configuration Wizard in graphical mode on a Windows platform, choose Start > Programs > Oracle WebLogic > WebLogic Server > Tools > Configuration Wizard.
  • To start the Configuration Wizard in graphical mode from a Windows command prompt or on UNIX systems:
    1. Log in to the system on which the product is installed.
    2. Open an MS-DOS command prompt window (on Windows) or a command shell (on UNIX).
    3. Go to the following directory:
      On Windows: WLHOME\common\bin
      On UNIX: WLHOME/common/bin
      where WLHOME is the directory in which WebLogic Server is installed.
    4. Execute the following command:
      On Windows: config.cmd
      On UNIX: sh

      When you run the config.cmd or command, the following error message might be displayed to indicate that the default cache directory is not valid:
      *sys-package-mgr*: can't create package cache dir
      You can change the cache directory by including the -Dpython.cachedir=valid_directory option in the command line.
      The Welcome screen is displayed.

When asked for a domain name, place whatever you prefer but note it down because we are going to need it later on.
For the sake of this example, the name of the domain is base_domain
(image taken from )

Another important step is the administrator user name and password. This is important since you will be using those credentials to administer the domain. So when you reach the following step, make sure that you remember the username and password! For the sake of this example we use weblogic / welcome1

Note that we do not need any managed servers or clustering for this example. No JDBC  datasources or something similar. Just a simple domain.
So when you reach this step (image taken from )

Leave everything unselected. We dont need them for this example.

After you finish the wizard, you have a new domain!! hooray!!

Start and Stop the domain
Now it is time to start the domain you have previously created.
According to the official documentation
WL_HOME\samples\domains\medrec\bin\startWebLogic.cmd (Windows)

WL_HOME is the installation path of weblogic. That is, the path you chose to install weblogic in the previous steps.
After WL_HOME follows the path that leads to the .cmd script that starts the admin server.
In this example the path is the following:


The simplest way to call the script would be through a cmd prompt.  open a cmd prompt and go to the folder of the script and just call it. This will start your admin server of your domain.

There is another way of starting your domain. Through the start menu.
Depending on your windows version, you will be able to navigate to the same script call from the start menu. The installation has took care of everything and added the appropriate links for you.
So in your start menu you will be able to see something like the following:


It is exactly the same process but with different script.
As you see in the above img, you already have the related link.
However there is an additional way.  Just go to the cmd window that runs the server process and simply press ctr+c . This will kill the running process on the cmd window and it will stop the server.

That is all about weblogic for now!
Next step, lets create a sample application using Maven.

No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...