Archive

Archive for August 29th, 2009

Weblogic (10.3) and Maven Integration – Part 1

August 29th, 2009 mohan No comments


(Note: 08/24/2009 This was posted in my old blog here, since the part 2 of the article is available on this blog. I’m moving the content here, with the original published date.)
(Update: The content has been slightly updated)

So another one for my notes. After searching in-vain for proper way to integrate the Weblogic 10.3 with maven, I think the solution below is working very well for me. We are going to use the weblogic-maven-plugin from codehaus. All the current solution including the plugin documentation requires either installing a bunch of jars from the weblogic installation. Please make sure you satisfy the requirements below.
Requirements:

  • You have a WL 10.3 installation
  • You are running JDK5 and above.
  • Maven 2.0.9 or above

Step By Step Guide

We will break it down into three main steps. One of the steps could be avoided if the weblogic-maven-plugin authors did not hard-code weblogic dependencies which are not available in the Maven repositories anyway (or if maven could support excluding plugin dependencies).

  1. Building the uber weblogic jar and publishing it to your local or organization repository.
  2. Downloading the weblogic-maven-plugin pom and jar.
  3. Configuring WL 10.3 a non-ssl admin channel.

1. Building the uber weblogic jar

(Updated content):

  • Install omitted jars: The wllfullclient jar process that is detailed next, is missing one required jar, so we will install that first and its location is:
<WL_HOME>\modules
  • Install into Maven Repository (Local, shown here): So now, let’s install it to the maven repo, also the coordinates are important for the next step when we install the full weblogic client jar.
C:\> <WL_HOME>\modules
C:\> mvn install:install-file -Dfile=com.bea.core.descriptor.wl_1.1.0.0.jar -DgroupId=com.bea.weblogic -DartifactId=core-descriptor-wl -Dversion=1.1.0.0 -DgeneratePom=true -Dpackaging=true
  • Build the wlfullclient.jar: There is a way to build a full weblogic client jar, so we don’t have to figure out what jars we need. For this of course you need a WL 10.3 installation. The instruction are actually given here (weblogic jarbuilder tool). If you follow the steps then you should have a wlfullclient.jar, in the WL_HOME/sever/lib folder. Here is a log for my installation of Weblogic 10.3 after following the instructions.
C:\> cd <WL_HOME>\wlserver_10.3\server\lib
C:\> java -jar ../../../modules/com.bea.core.jarbuilder_1.2.0.0.jar
...
...
Created new jar file: ...\wlserver_10.3\server\lib\wlfullclient.jar
  • Create a POM file for wlfullclient.jar: We will actually create a POM file, instead of generating the POM, open up a text editor paste the contents below and name the file wlfullclient-103.pom. The reason we do this, so we don’t have to put multiple dependencies in the plugin configuration. This was a result of wlfullclient not including the missing module. So here is the POM for wlfullclient.jar (NOTE: in the dependencies section)
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"

>
<modelversion>4.0.0</modelversion>

<groupid>weblogic</groupid>
<artifactid>wlfullclient</artifactid>
<version>10.3</version>
<packaging>jar</packaging>

<name>Weblogic Full Client Library</name>
<description><![CDATA[
Note, this is created because there are some required dependencies that are
missing from the full client jar generator script.
]]></description>
<licenses>
<license>
<name> OTN Development and Distribution License Agreement</name>
<url>http://www.oracle.com//technology/software/popup-license/distribution-license.html</url>
</license>
</licenses>

<dependencies>
<dependency>
<groupid>com.bea.weblogic</groupid>
<artifactid>core-descriptor-wl</artifactid>
<version>1.1.0.0</version>
</dependency>
</dependencies>

</project>
  • Install wlfullclient.jar to Maven Repository: Now, we will use maven to install this for this example in our local repository (you can use deploy to publish it to your org. repo, such as Nexus).
$ mvn install:install-file -Dfile=wlfullclient.jar -DgroupId=weblogic -DartifactId=wlfullclient -Dversion=10.3 -Dpackaging=jar -DpomFile=wlfullclient-103.pom

Note the use of the character “\” is just a *nix newline escape, basically the whole thing above should be on one line.
Also notice the pomFile value.

2. Download and modify the weblogic-maven-plugin POM and jar

As mentioned before, we need to modify the pom because of hard coded dependency to weblogic. So what we do here is:

  1. Download the POM
  2. Change the version in the pom and delete the 2 weblogic dependencies.
  3. Then install the Pom and the associated jar into our repository (local).
2.1 Download the weblogic-maven-plugin POM.

Download the weblogic-maven-plugin POM (2.9.1) and then also download the plugin jar.

2.2 Edit the downloaded POM

Open the downloaded POM from any editor. Comment out the any weblogic dependencies as shown below. And change the version, as shown below I am changing it to 2.9.1-001.

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"

<modelversion>4.0.0</modelversion>
<parent>
<artifactid>mojo</artifactid>
<groupid>org.codehaus.mojo</groupid>
<version>14</version>
</parent>
<prerequisites>
<maven>2.0</maven>
</prerequisites>
<artifactid>weblogic-maven-plugin</artifactid>
<packaging>maven-plugin</packaging>
<name>Weblogic Maven Plugin</name>
<version>2.9.1-001</version>  <!-- CHANGED -->
...
<dependencies>
...
<!--
<dependency>
<groupid>weblogic</groupid>
<artifactid>weblogic</artifactid>
<version>[9.0,11.0)</version>
</dependency>
<dependency>
<groupid>weblogic</groupid>
<artifactid>webservices</artifactid>
<version>[9.0,11.0)</version>
</dependency>
-->
...
</dependencies>
...
</project>
2.3 Install the edited POM and the plugin jar to your local repository.

Now we install it to our local repository (or a corp repo if you have one.). Please notice the -DpomFile argument this should be the edited POM from above.

C:\>mvn install:install-file -Dfile=weblogic-maven-plugin-2.9.1.jar -DpomFile=weblogic-maven-plugin-2.9.1-001.pom -DgroupId=org.codehaus.mojo -DartifactId=weblogic-maven-plugin -Dversion=2.9.1-001 -Dpackaging=maven-plugin

Important things to note above:

  • -DpomFile the pom file is the edited one as we did before, I called the edited pom weblogic-maven-plugin-2.9.1-001.pom
  • The version -Dversion=2.9.1-001
  • And the packaging (very important) -Dpackaging=maven-plugin

Now, of course in your project you would use this version of the installed plugin.

3. Create an admin channel in Weblogic 10.3

Ok, we need to do this step because for some reason WL 10.3, you can no longer do the deploys using the t3. Only SSL is allowed, and for some reason the uber jar does not include a particular implementation and I did not have the time to investigate it. Another post describing the process (Update: The steps is described here.)

Putting it all together

Ok, after you have done all the 3 steps, here is how the configuration looks like in your POM file. Enjoy and leave a comment if this was useful or need more clarification.

...
<plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>weblogic-maven-plugin</artifactid>
<version>2.9.1-001</version>
<inherited>true</inherited>
<configuration>
<adminserverhostname>localhost</adminserverhostname>
<adminserverport>10058</adminserverport>   <!-- CHANGE ME -->
<adminserverprotocol>t3</adminserverprotocol>
<userid>weblogic</userid> <!-- CHANGE ME -->
<password>weblogic</password> <!-- CHANGE ME -->
<upload>true</upload>
<remote>true</remote>
<verbose>true</verbose>
<debug>false</debug>
<targetnames>my_admin_server</targetnames> <!-- CHANGE ME -->
<noexit>true</noexit>
</configuration>
<dependencies>
<dependency>
<groupid>weblogic</groupid>
<artifactid>wlfullclient</artifactid>
<version>10.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
</plugin>

...

Few things to note here:

  • The adminServerPort corresponds to 10058, this is the port I configured in the Step 3 (admin channel)
  • Also note, the wlfullclient dependency I chose to add it here, instead of the edited pom in Step 2. Of course this requires Maven 2.0.9 and above.
  • Also the plugin version is 2.9.1-001 the one we installed in Step 2.

So that’s it, folks.

Categories: Weblogic Tags: