Installing and Using the NEW WebLogic 12 Maven Plug-In for Deployment

Markus Eisele
0
You might know, what the WebLogic Maven Plug-In is available since WLS 10.3.4.0. This nice little plug-in has been revised and updated with the recent WebLogic 12c release.

What changed?
Since the Maven support has been there for some time, it's interesting to look at what changed over time. Most notably, the old way of generating the weblogic-maven-plugin.jar is no longer required. You now find a pre-bundled version in $MW_HOME/wlserver/server/lib/wls-maven-plugin.jar the corresponding pom.xml is also there $MW_HOME/wlserver/server/lib/pom.xml. Since you don't have to use the jarbuilder you can simply install the dependency almost like you did before. Change to $MW_HOME/wlserver/server/lib/ and type:

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


Now you can use it.

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

Or add the corresponding build element to your projects pom.xml. There is one thing you need to be careful of. The class name changed: it's not longer weblogic-maven-plugin but wls-maven-plugin. This is especially important if you already have an older plugin in place.
If you don't like to use the full-qualified class name, you can add the following lines to your ~/.m2/settings.xml prior to executing the mvn install commands from above!

<pluginGroups>
  <pluginGroup>com.oracle.weblogic</pluginGroup>
</pluginGroups>


Deployment Goals until today

Until today the plug-in only supports the maven goals in the following table.
weblogic:deployDeploys or redeploys an application or module.
weblogic:undeployStops the deployment and removes staged files from target servers.
weblogic:redeployRedeploys a running application or part of a running application.
weblogic:start-appStarts an application.
weblogic:stop-appStops an application.
weblogic:list-appsLists the deployment names for applications and standalone modules deployed, distributed, or installed in the domain.
weblogic:update-appUpdates an application's deployment plan by redistributing the plan files and reconfiguring the application based on the new plan contents.
weblogic:helpLists all the deployment goals

New Goals with 12.1.1.1
The 12c release introduces six new goals which makes using WLS in CI environments a breeze.
mvn wls:install Automated WebLogic server installation from zip file
mvn wls:uninstall Automated WebLogic server de-installation
mvn wls:create-domain
  Create a domain for WebLogic Server using the default domain template.
  For more complex domain creation use the WLST goal.
mvn wls:start-serverStart WebLogic Server 
mvn wls:wlstExecute inline and external WLS scripts
mvn wls:appc
The appc compiler generates and compiles the classes needed to deploy
EJBs and JSPs to WebLogic Server. It also validates the deployment
descriptors for compliance with the current specifications at both the
individual module level and the application level.

wls:install
This goal installs WLS into a local directory to enable it to be used execute the other goals, as well as a installation to create a WLS domain that can be used to deploy and test the application represented as the Maven project. To install, you need a distribution to install. This is specified using the <artifactLocation> configuration element in the wls maven plugin section of the pom.xml, or specify it using the –DartifactLocation property when Maven is invoked.
You can even distribute the WLS zip install via your central maven repository. First step is to install it:

mvn install:install-file -Dfile=wls1211_dev.zip -DgroupId=com.oracle.weblogic -DartifactId=wls-dev -Dpackaging=zip -Dversion=12.1.1.1

The target directory for the installation is specified using the optional weblogicHome configuration element. This is set to ${basedir}/Oracle/Software by default. Specifying a <middlewareHome> value will direct the install to be performed in the specified location. The following goal will install a WLS into d:\wls12:
mvn wls:install -DartifactLocation=com.oracle.weblogic:wls-dev:zip:12.1.1.1 - DmiddlewareHome=d:\wls12
How cool is that? Think about the endless possibilities rolling out the WLS instances and configurations to a complete team! But we are only half through. We also need a domain:

wls:create-domain
The location of the domain is specified using the optional <domainHome> configuration element. By default <domainHome> is set to ${basedir}/Oracle/Domains so it will be created in an Oracle/Domains subdirectory of the root directory of the Maven project. The WLS installation to be used is specified using the optional <middlewareHome> configuration element. This is set to ${basedir}/Oracle/Software by default, so if the default location has been used to execute the install goal, it can be left out of this goal. Additionally you only need to provide a user and a password via the identical named parameters.

mvn wls:create-domain -DdomainHome=d:\wls12\user_projects\domain1 -DmiddlewareHome=d:\wls12 -Duser=system -Dpassword=weblogic1

Now you have setup your domain completely.

wls:start-server
So, let's start the server. The start-server goal executes a startWebLogic command on a given domain, starting the WebLogic Server instance. This goal also uses the <middlewareHome> and <domainHome> configuration elements to specify the location of the WLS installation and domain to use.

mvn wls:start-server -DdomainHome=d:\wls12\user_projects\domain1 -DmiddlewareHome=d:\wls12

That's it, try to access: http://localhost:7001/console/ and you will see, that your newly created domain is up and running!

mvn wls:wlst
The WLST goal enables the WebLogic Scripting Tool (WLST) to be used to execute scripts that configure resources or perform other operational actions on a WebLogic Server domain. The WLST used by the wlst Maven goal is the standard environment WebLogic Server WLST environment so all existing scripts should be able to be used. The relevant configuration elements are user, password and filename. Where the last one identifies your WLST script.

mvn wls:wlst -DartifactLocation=com.oracle.weblogic:wls-dev:zip:12.1.1.1 -Duser=system -Dpassword=weblogic1 -Dfilename=create-app-ressource.py

Wonderful. Now you have your system configured with all needed resources.

mvn wls:appc
The appc goal executes the WebLogic Server application compiler tool to prepare the application for deployment. The appc compiler generates and compiles the classes needed to deploy EJBs and JSPs to WebLogic Server. It also validates the deployment descriptors for compliance with the current specifications at both the individual module level and the application level.

That's all! Give it a try! It is simple as Maven :) And to make this a little more handy for you I prepared a sample maven project with all you need to setup a environment for WebLogic server.
all you need to do is to install the zip distribution and the wls-maven plugin to your local repository as described above. Download the sample maven project (it can be opened in NetBeans right away) and try:

mvn install

if you want to run it on WebLogic server, simply revise the path settings in the properties section of the pom.xml (<fmw.home>d:\temp\wls\</fmw.home>) and execute:

mvn install -Pdeploy


Post a Comment

0Comments

Post a Comment (0)