Deploying WebLogic applications with Maven

In my last post, I talked about one exciting new feature in WebLogic 11g, support for Mac OS X.  Now, I want to cover another exciting new feature – a Maven plugin which allows you to incorporate deployment of your applications to WebLogic into your Maven builds.

I love this new feature because it makes it so easy to compile all my Java source and web artefacts, build a deployment archive and deploy it WebLogic Server in one easy action!  I hope you like it too!

A big thank you to Steve Button for bringing this to my attention, helping me to get it working on Mac OS X and sharing some helpful hints and tips.

Setting up the plugin

First, let’s set up the Maven plugin.  You will need WebLogic Server 10.3.4 installed to do this.  I used the convenient new ‘ZIP Distribution’ which is built for developers.  I used Maven 2.2.1 and JDK 1.6 on Mac OS X 10.6 to write this article.

First, we need to create the plugin using the wljarbuilder utility.  Execute the following commands from your WebLogic home directory:

# cd <WL_HOME>/wlserver/server/lib
# java -jar wljarbuilder.jar -profile weblogic-maven-plugin

This will create a new file called weblogic-maven-plugin.jar in that same directory.  Next, we need to extract the Maven POM from the jar file, and place it in the same directory.  You may want to extract it into a temporary directory and then move it.

# jar xvf <WL_HOME>/wlserver/server/lib/weblogic-maven-plugin.jar META-INF/maven/
# mv META-INF/maven/ <WL_HOME>/wlserver/server/lib

Before installing the WebLogic Maven plugin into your local repository, it is important to make sure all of the necessary dependencies have been downloaded.

# cd <WL_HOME>/wlserver/server/lib
# mvn install

Note: before you continue, if you want to use the WebLogic plugin from the command line, you might want to set up a short name so you can type shorter goal names.  You have to do this now, before you continue.  To set up a short name, weblogic, you will need to add the following entries to your ~/.m2/settings.xml Maven configuration file…


… and add the following to the pom.xml that you just extracted into your <WL_HOME>/wlserver/server/lib directory.


Now we can install the plugin.  You must run mvn install first to make sure it downloads the dependencies and recognises the prefix we have defined.

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

The plugin will now be available for use.  We can execute the ‘help’ goal to test it:

# mvn

Or, if you set up the short name:

# mvn weblogic:help

Using the plugin to deploy an application

Probably the most convenient way to use the WebLogic Maven plugin, is to incorporate it into your standard build.  Let’s look at how we can set up a project to compile, test, package and deploy to WebLogic by simply typing mvn deploy.

First, create a new Maven project.  I used mvn archetype:generate, selected the webapp-javaee6 template, and provided the necessary details.  I called my project wldemo.

We need to add a few items to the pom.xml to tell Maven to deploy the application to WebLogic.

  <!-- use the following if you're not using a snapshot version. -->
    <name>local repository</name>
  <!-- use the following if you ARE using a snapshot version. -->
    <name>local snapshot repository</name>

You will have to update the settings to match your environment, as follows:

Setting      Meaning
-----------  ----------------------------------------
adminurl     WebLogic T3 URL for your Admin Server
user         WebLogic administrative user
password     WebLogic administrative user's password
name         Name of application
remote       Indicates a remote server
upload       Indicates the war file must be uploaded
targets      The server, cluster, etc. to deploy to

In addition to the WebLogic settings in the plugins section, you need to set up the distributionManagement section to point to your local repository so that the deploy phase can run successfully.

Now we are ready to build, test and deploy our application!  In real life, you might want to write some code first – but for this example, we will just use the simple JSP page that comes in the template.

# mvn deploy

After a few moments, you application will be built and deployed.  You can see it right there in the WebLogic Server console:

You can now hit the application at http://yourserver:7001/wldemo.  You should get a clean page with the message ‘Hello World!

Now you can make changes and quickly and easily deploy them to your server for testing with a single, simple command!  The plugin will also let you start and stop applications and undeploy them.


Where to find more information

You might want to read over the documentation here for more details on the goals and parameters that are available in the plugin.

About Mark Nelson

Mark Nelson is a Developer Evangelist at Oracle, focusing on microservices and messaging. Before this role, Mark was an Architect in the Enterprise Cloud-Native Java Team, the Verrazzano Enterprise Container Platform project, worked on Wercker, WebLogic and was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

7 Responses to Deploying WebLogic applications with Maven

  1. Pingback: Deploying WebLogic applications with Maven

  2. Pingback: Improving JMS Performance on WebLogic | RedStack

  3. Pingback: 为Maven安装WebLogic Server插件 | Oracle融合中间件研究

  4. Pingback: Setting up the development environment for the Worklist | RedStack

  5. Pingback: Creating the worklist project | RedStack

  6. Pingback: Extending Continuous Integration to include Human Task UI projects | RedStack

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s