Weblogic 10.3 and Maven Integration

(Update: I’m moving this article and the t3 channel creation step to my permanent blog here)

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

Requirements:

  • You have a WL 10.3 installation
  • JDK5
  • Maven 2.0.9 or above

Required Steps

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

Step 1. Building the uber weblogic 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 how it looks like:

C:\>java -jar ...
...
Created new jar file: C:\..\server\lib\wlfullclient.jar
...
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 -DgeneratePom=true

Note the use of the character "\" is just a *nix newline escape, basically the whole thing above should be on one line.
 

Step 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:

  • Download the POM
  • Change the version in the pom and delete the 2 weblogic dependencies
  • Then install the Pom and the associated jar into our repository (local).

Download the POM & Jar

Download the POM from here (weblogic-maven-plugin pom) and then also download the jar. So first we download the POM and change as shown below:

<project xmlns=http://maven.apache.org/POM/4.0.0>
  <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>
        ...
    <!-- COMMENT OUT THE 2 WL 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>

Notice the comment CHANGED lines. Now we install this pom and the downloaded jar into our local repository because of the changes.

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.

Step 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. <TODO>Another post describing the process</TODO> (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. 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>7001</adminServerPort>
        <adminServerProtocol>t3</adminServerProtocol>
        <userId>weblogic</userId>
        <password>weblogic</password>
        <upload>true</upload>
        <remote>true</remote>
        <verbose>true</verbose>
        <debug>false</debug>
        <targetNames>my_admin_server</targetNames>
        <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 7001, 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.

Comments (13)

Happy New Year

Happy New Year to everyone, hopefully 2009 I can find the time to revive the blog🙂

Comments (2)

Maven 2 & m2eclipse

Finally, we have a plugin for M2 that rocks! You can get the development snapshots here:
m2eclipse development snapshots

Thanks to the folks at sonatype. Listed below are some of the cool things you can do, this takes Java Development productivity to new heights:

  • The killer POM editor (form based, nice)
  • Checkout projects directly from SCM and run maven goals before importing them..
  • Awesome multi-module project support. Yes, finally this works, no more generating eclipse projects file from maven (mvn eclipse:eclipse)
  • Dependencies via workspace resolution, now you can refactor across projects, absolutely awesome
  • Of course the indexer to search for artifacts
  • A wizard for generating projects (multi-module and from the various archetypes available)

I have been running with Ganymede and the 0.96 version, very occasional NPE. I will try to post some tips over the next few days. If you have not looked at Maven 2 lately or have been frustrated with the IDE support, no more.

I was very much in favor of Q4E but for some reason over the last few months there has been a tremendous spike in the m2eclipse effort and is pretty much killed the other efforts.

Leave a Comment

Maven 2 Archetype Plugin and repositories

Ok, I have been trying to setup an Maven 2 internal repository for our company (evaluated artifactory and proximity), dumped all our Maven 2 archetypes to the internal repository. So, configured settings.xml to reflect the shiny new repository and decided to try out one of archetype:create downloaded from the new repos, lo and behold the dreaded BUILD ERROR *%%$%, the archetype-plugin in all its wisdom refused to consider my new shiny repos (always going to the mothership central). After four hours of redeploying the archetype, changing repositories, settings.xml it turns out (thanks to google) it is an open issue with maven or the archetype-plugin. In any case the solution is to provide a -DremoteRepositories system property on the command line.

Comments (2)

Maven 2 settings.xml

Strange thing, if you use a <activeByDefault>true</activeByDefault> in a profile, and then checking for activated profiles using mvn help:active-profiles, shows the profile id containing the above element (child of activation element) twice?? So does it mean it is activated twice? Anyways, I added a <activeProfiles> element in the settings.xml and removed the above element from the affected profile, now reissuing the mvn help:active-profiles, the profile id shows up only once.

Another one of those mysterious maven 2 things, sigh.

Leave a Comment

Maven 2, TestNG and Surefire-plugin

Since I have decided to use this blog as a easy access to find things that I don’t want to search all over, here is the way I configure my maven-2 projects with TestNG. Here is the relevant pom entry in <build><plugins>

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.4-SNAPSHOT</version>
  <configuration>
    <argLine>-Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m</argLine>
    <parallel>true</parallel>
    <suiteXmlFiles>
      <suiteXmlFile>src/test/config/testng.xml</suiteXmlFile>
    </suiteXmlFiles>
  </configuration>
</plugin>

You must make sure that the plugin snapshot repository is configured in your pom.xml, otherwise the 2.4-SNAPSHOT jar will not be found. To do that make sure the following element is defined in the <pluginRepositories> element:

<pluginRepository>
  <id>apache-snapshots</id>
  <url>http://people.apache.org/repo/m2-snapshot-repository</url>
  <releases>
    <enabled>false</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</pluginRepository>
<pluginRepository>

Note, I put all my TestNG configuration information in testng.xml. Without this file you would get all kinds of strange errors, when the surefire plugin triggers the test goal. Below is a sample testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Sample_TestNG_Suite" verbose="4">
  <test name="DefaultTestPackage">
    <packages>
      <package name="org.anonymous.package"/>
    </packages>
  </test>
</suite>

You also need to make sure the testNG <dependency> element is available in the pom, lit below

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>5.6</version>
  <scope>test</scope>
  <classifier>jdk15</classifier>
</dependency>

Remember 5.6 is not yet available in central repositories, to install it locally use the following standard maven-2 install goal (NOTE: the whole command below is a single line)

$ mvn install:install-file -Dfile=testng-5.6-jdk15.jar -DgroupId=org.testng -DartifactId=testng -Dversion=5.6 -Dpackaging=jar \ -Dclassifier=jdk15 -DgeneratePom=true

That’s it, you should be good to go, just annotate (I use JDK5) your test POJO’s and surefire plugin will be triggered by the default maven2 lifecycle.

Comments (2)

OpenSUSE 10.2, Beryl-SVN and Dell D820

Never found the time to show off my rig where most of my work get done. As the old adage goes “picture is worth gazillion words” and without further ado:

I got the cairo clock ticking in the above picture.

The rig has been an excellent development environment, especially if you work with a lot of open source projects, some day when I get more time I can probably write the setup. And yes, windows is banished under a vmware session. The last picture show off Eclipse/Europa edition.

Leave a Comment

Older Posts »