Thursday, July 4, 2013

WebLogic: Maven Deploy to Oracle Weblogic. Step By Step. The Basics.


Below is the list of link of a 4-part-article about WebLogic and Maven. It is a very detailed article and it assumes no prior knowledge about WebLogic or Maven.

written by Dimitrios Stasinopoulos on dstas.blogspot.com


 

 Sample from part 1:

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

So Far
Up to this point, we spent some time trying to get acquainted with various stuff.. We learned about Maven.. we learned about Weblogic, we learned a bit about Netbeans and we have created two maven projects.

Aaand.. at this final part of this series.. we are going to deploy our maven applications to our weblogic server.

Everything is setup and all we have to do is a few more steps.

Remember when we talked about Maven is using plugins?
Well, this is what we have to do, use a plugin that will help us deploy our maven application.
But which plugin?

Oracle provides a way in doing things

http://docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm

 ....
  • wls-maven-plugin—Delivered in WebLogic Server 12c, provides enhanced functionality to install, start and stop servers, create domains, execute WLST scripts, and compile and deploy applications. In addition to its shortened, easier to specify name, the extended functionality in the wls-maven-plugin requires a local WebLogic Server installation, in contrast to the weblogic-maven-plugin, which is generated as a standalone, self-contained JAR file. However, with the wls-maven-plugin, you can install WebLogic Server from within your Maven environment to fulfill the local WebLogic Server requirement. For more information about this plug-in, see Configuring the WebLogic Development Maven Plug-In..
.....

So we understand that Weblogic 12c already provides the maven plugin for us.

All we have to do is to install  that plugin to our repository.
Locate the plugin and the pom.xml 
According to the documentation

(http://docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm)
The wls-maven-plugin is located in the MW_HOME/wlserver_12.1/server/lib directory, where MW_HOME represents the top-level installation directory for all Fusion Middleware products installed on one machine; for example, c:\Oracle\Middleware. The plug-in is provided as a pre-built JAR file and accompanying pom.xml file:
  • MW_HOME/wlserver_12.1/server/lib/wls-maven-plugin.jar
  • MW_HOME/wlserver_12.1/server/lib/pom.xml


In our case (for this example):

C:\Oracle\Middleware\wls1211\wlserver_12.1\server\lib\wls-maven-plugin.jar
C:\Oracle\Middleware\wls1211\wlserver_12.1\server\lib\pom.xml

Now that we have located them. Lets install it.
Open a command prompt and navigate to  C:\Oracle\Middleware\wls1211\wlserver_12.1\server\lib\ (or your middleware home\wlserver_12.1\server\lib)


Next, execute the following command

mvn install -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml

Normally you will see a BUILD SUCCESS at the end.

In case you dont remember what mvn install  is and what it does, check out this link
http://maven.apache.org/plugins/maven-install-plugin/

According to the official documentation:
is used to automatically install the project's main artifact (the JAR, WAR or EAR), its POM and any attached artifacts (sources, javadoc, etc) produced by a particular project.

Next, you have to call the install-file goal in order to place the files in the proper place in the local repository (
as the documentation says here: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html)

mvn install:install-file -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml
 Normally you will see a BUILD SUCCESS at the end. 
 
The above goal, will set up everything properly for us. So what we have done so far is:

We installed the project's main artifact, which is the wls-maven-plugin, and we then setup everything properly to our local repository.

How do we know that? How do we know that we have done everything ok?
First of all, we have just added a new plugin into our local repository. How do we call it?
Where is it installed?

It is easy to find, if you paid attention to the install:install-file


ok so we know where is the plugin, under com.oracle.weblogic. But how do we call the plugin's goals?

with the following command:

mvn com.oracle.weblogic:wls-maven-plugin:help
 

Now, that is a bit long, isnt it? It would be great if we could do something like the following:
mvn wls:help ? right? It certainly looks better and easier to remember.
In order to do that we have to do   two things:

1) Assign a prefix to our plugin. But wait! this is already done by Oracle. As you remember there is a pom.xml in the lib folder