Installing and Using the WebLogic 10.3.4.0 Maven Plug-In for Deployment

Markus Eisele
8
It happened very silent. The Oracle Middleware 11g Patchset 3 is available since yesterday. To me all the fancy new Oracle stuff (ADF, SOA and more) is not too important at the moment. But one thing is: The backbone of it. My all time favorite WebLogic Server. It's now at version number 10.3.4.0 and comes with some minor tweaks in general this time. One of the things I was waiting for since some time is the new WebLogic Maven plugin. Now you can use an Apache Maven plug-in for WebLogic Server (weblogic-maven-plugin) to perform deployment operations similar to those supported by the command-line utility, weblogic.Deployer. The plug-in lets you deploy, redeploy, update, and such, applications built using Maven to WebLogic Server from within the Maven environment.

Getting started
Get your copy of the latest WebLogic (together with Coherence and OEPE) and install it. Download and configure Apache Maven 2.x.
Next is to configure the new plugins. Everything gets a lot simpler if you start with a blank domain. Start the configuration wizard and create one. Execute the user_projects\domains\base_domain\bin\setDomainEnv.cmd/.sh to prepare your environment. Now we can go on and configure the plugin jar file. This could be done with the WebLogic JarBuilder Tool (wljarbuilder) which ist located at MW_HOME/wlserver_10.3/server/lib/ change to that folder and execute: java -jar wljarbuilder.jar -profile weblogic-maven-plugin. This will generate your barely 59 MB big weblogic-maven-plugin.jar. Don't think about the weird output ;)
Open the jar file with your favorite ZIP tool and extract the META-INF\maven\com.oracle.weblogic\weblogic-maven-plugin\pom.xml to MW_HOME/wlserver_10.3/server/lib. If you look at the file you get the maven dependency information:

<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>10.3.4</version>

These fields identify the plug-in and mark a specific place in a Maven repository, acting like a coordinate system for Maven projects.
Now you have to install the plugin to your local maven repository. Execute:

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

If you have never ever used Maven before, you should probably go and read other pages before but if you came here and you are wondering about what's happening after you executed this command for the first time ever: Maven is downloading the internet to your local repository and finally installs the generated jar file there, too.

Using the WebLogic Maven Plugin
You can use the plugin in two modes. First is from the cmd line. You can use the following goals: deploy, list-apps, redeploy,start-app,stop-app,undeploy,update-app.
If you followed my explanation you can simply type the following:
mvn com.oracle.weblogic:weblogic-maven-plugin:help
Or you can include the plugin in your own applications's pom.xml file:

...
<build>
<plugins>
<plugin>
<groupid>com.oracle.weblogic</groupId>
<artifactid>weblogic-maven-plugin</artifactId>
<version>10.3.4</version>
<configuration>
<adminurl>t3://localhost:7001</adminurl>
<user>system</user>
<password>weblogic1</password>
<upload>true</upload>
<action>deploy</action>
<remote>false</remote>
<verbose>true</verbose>
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
<name>${project.build.finalName}</name>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...


You can add the plug-in into any life cycle phase of the project. Optionally, you can add a goal to any of the default Maven life cycle phases by adding an executions tag in the pom.xml file. The goal is then bound to that particular phase of the Maven life cycle. As shown above the goal is bound to the "install" phase of the life cycle. By doing this, every time you run the mvn install command, the deployment plug-in is also called.

Wondering about the long command?
The cmd line command is quite long. You can and should shorten the invocation name of the plugin. A couple of steps have to be taken to achieve this.
You have to change the pom.xml file and add:

<build>
<plugins>
<plugin>
<artifactid>maven-plugin-plugin</artifactId>
<version>2.3</version>
<configuration>
<goalprefix>weblogic</goalPrefix>
</configuration>
</plugin>
</plugins>
</build>

After that modify the settings.xml file located in your $HOME/.m2 directory with the following lines:

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

before you provision the plug-in in your Maven repository.

After all this is done, you can call all commands with a shortened version:
mvn weblogic:deploy

Conclusion
Even if the documentation states, that the plugin should use Maven 2.x I tried everything with Maven 3 and did not discover any problems in general.
I will give it a test drive production near and will report further findings. At the moment everything looks very promising and simple. Thanks guys for providing this one!

Post a Comment

8Comments

  1. It doesn't support the most important feature for a developer, WLS Split Deploy, better if you use the beabuild-plugin

    ReplyDelete
  2. Luca,

    that's definitely a point. I was hoping for any good ideas related to developer productivity in this, too. But I guess it's not only the fault of the product. It's simply the way maven works.

    Thanks for the comment,
    M

    ReplyDelete
  3. Marcelo,
    no, it's not. It's the commercial application server from Oracle.
    If you are looking for a free and open Java EE appserver, give GlassFish a try!
    -M.

    ReplyDelete
  4. How can Patchset 3 be identified? Does the WL server state it during startup or in the Admin Console?

    A colleague who tried the Maven plugin has found some issues, so I'm wondering, if we had the latest version of 11g...

    Thanks,
    Werner

    ReplyDelete
  5. Hi Werner,

    it's printed to stdout during startup:
    "WebLogic Server 10.3.4.0.
    the 4.0 is the PS3 indicator :)
    You can also fire up the http://localhost:7001/console and look bottom left into the blue area. That also states the version number.

    Thanks,
    M

    ReplyDelete
  6. Hi everyone.

    I having issues while running the start-app goal. It´s hanging for at least 1h and after that my eclipse console says that the goal finished successfully but the app( an ear file) is in prepared state on my weblogic console.

    Any help would be appreciated.

    PS : What Im using :

    Weblogic 10.3
    Maven 2.2.1

    ReplyDelete
  7. Hi Everyone,

    what does the tag:
    deploy
    in the pom.xml mean ?

    I try to figure out, how I define the tag only in deploy goal because during the undeploy I got an Error, that I must not define the source tag.

    Any help would be appreciated.

    ReplyDelete
Post a Comment