News, tips, partners, and perspectives for the Oracle Solaris operating system

DevOps Hands on Lab - Connecting Maven to Oracle WebLogic Server

Continuing on from last week's DevOps toolchain Part 1 blog. This is Part 2 on how to set up a simple DevOps toolchain on Oracle Solaris with tools like Jenkins, Maven, Git, and WebLogic Server. This is based on a Hands on Lab we did at Oracle OpenWorld this year and the toolchain at the end  of the Hands on Lab basically looks like this:

In this second part we'll be installing Maven and creating and loading the Oracle Maven Plugins for Oracle WebLogic Server.

To achieve this we'll first install the second Solaris Zone called j-m_zone and then install Java, Git, and Maven. At this point we can create/build the Oracle Maven Plugins for Oracle WebLogic Server with the WebLogic install in the wls_zone, pull them across and then use them to create, upload, and test a WebLogic demo application.

The basic assumption is that you're continuing on working in the same environment as with Part 1, because we'll need the WebLogic install to be there to create the plugins and later connect to.

1. Installing the Jenkins-Maven Zone

This procedure is very similar to the earlier install of the wls_zone so we'll only do the abbreviated version here.

First (as user root in the Global Zone) configure the zone:

root@solaris:~# zonecfg -z j-m_zone
Use 'create' to begin configuring a new zone.
zonecfg:j-m_zone> create
create: Using system default template 'SYSdefault'
zonecfg:j-m_zone> set autoboot=true
zonecfg:j-m_zone> set zonepath=/zones/j-m_zone
zonecfg:j-m_zone> verify
zonecfg:j-m_zone> commit
zonecfg:j-m_zone> exit

Then install it:

root@solaris:~# zoneadm -z j-m_zone install

And once that's run through boot and connect to the zone console to go through the initial system configuration steps:

root@solaris:~# zoneadm -z j-m_zone boot; zlogin -C j-m_zone

This will again take you through the texted based configuration screen and once you've finished this and the zone has rebooted you can break out of the console (using ~.) and your zone is up and running.

Note that before you break out of the console you might want to log in and run the ipadm command to get the IP address the zone has acquired from DHCP (if you've chosen to use DHCP instead of a fixed IP address). You can of course at a later point in time from the Global Zone always just run it in the context of the zone by running:

root@solaris:~# zlogin j-m_zone ipadm

This will run that single command in the context of the zone and on exit return you to the Global Zone.

2. Create/Build Oracle Maven WebLogic Server Plugins

Before we go any further with the Install of Maven, we go back to the WebLogic installation and use it to create the plugins we're looking for. The WebLogic install includes the files necessary to build the plugins as well as the version of Maven needed to do this. So once logged into the wls_zone you need to find the Maven binaries and then use them to build the plugins.

First log back in to the wls_zone and become user oracle. You can do this in one step by using the zlogin -l option. And then we add the Maven that ships with WebLogic Server to the PATH:

root@solaris:~# zlogin -l oracle wls_zone
[Connected to zone 'wls_zone' pts/4]
Last login: Fri Sep 15 07:31:15 2017 from
Oracle Corporation      SunOS 5.11      11.3    July 2017
oracle@wls_zone:~$ export PATH=$PATH:/u01/oracle/oracle_common/modules/org.apache.maven_3.2.5/bin
oracle@wls_zone:~$ mvn -v
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T09:29:23-08:00)
Maven home: /u01/oracle/oracle_common/modules/org.apache.maven_3.2.5
Java version: 1.8.0_141, vendor: Oracle Corporation
Java home: /usr/jdk/instances/jdk1.8.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "sunos", version: "5.11", arch: "amd64", family: "unix"

Next is an optional point. Maven will need to connect with it's repository (it's default is https://repo.maven.apache.org) and if you need to use a proxy to get to this repository because it's not directly visible this needs to be defined. In Maven this is done through the ~/.m2/settings.xml file and it should look something like this:

oracle@wls_zone:~$ vi ~/.m2/settings.xml
oracle@wls_zone:~$ cat ~/.m2/settings.xml 
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"

Now we can run the first step, installing the Oracle Maven Synchronization Plug-In:

oracle@wls_zone:~$ cd oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1/
oracle@wls_zone:~/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1$ ls
oracle-maven-sync-12.2.1.jar  oracle-maven-sync-12.2.1.pom
oracle@wls_zone:~/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1$ mvn install:install-file -DpomFile=oracle-maven-sync-12.2.1.pom -Dfile=oracle-maven-sync-12.2.1.jar
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 5.5 KB/sec)


[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.530 s
[INFO] Finished at: 2017-09-11T19:38:00-07:00
[INFO] Final Memory: 11M/123M
[INFO] ------------------------------------------------------------------------

Note: Details on this step can be found on the Installing and Configuring Maven for Build Automation and Dependency Management page.

Now we push the plugin into the directory we want (in this case /u01/oracle):

oracle@wls_zone:~/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1$ mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/u01/oracle -DtestingOnly=false
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] --- oracle-maven-sync:12.2.1-2-0:push (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Found 491 location files in /u01/oracle/wlserver/plugins/maven
[INFO] Installing /u01/oracle/wlserver/modules/com.bea.core.xml.weblogic.xpath.jar to /u01/oracle/.m2/repository/com/oracle/weblogic/com.bea.core.xml.weblogic.xpath/12.2.1-2-0/com.bea.core.xml.weblogic.xpath-12.2.1-2-0.jar


[INFO] Installing /u01/oracle/oracle_common/plugins/maven/com/oracle/weblogic/oracle.apache.commons.collections.mod/3.2.0/oracle.apache.commons.collections.mod-3.2.0.pom to /u01/oracle/.m2/repository/com/oracle/weblogic/oracle.apache.commons.collections.mod/3.2.0-0-2/oracle.apache.commons.collections.mod-3.2.0-0-2.pom
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Number of artifacts pushed: 983
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] No issues encountered.
[INFO] This operation may have added/updated archetypes in your repository.
[INFO] To update your archetype catalog, you should run:
[INFO] 'mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml'
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.209 s
[INFO] Finished at: 2017-09-11T19:51:36-07:00
[INFO] Final Memory: 12M/123M
[INFO] ------------------------------------------------------------------------

Now we can inspect the new plugin:

oracle@wls_zone:~/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1$ mvn help:describe -DgroupId=com.oracle.weblogic -DartifactId=weblogic-maven-plugin -Dversion=12.2.1-2-0
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ standalone-pom ---
[INFO] com.oracle.weblogic:weblogic-maven-plugin:12.2.1-2-0

Name: weblogic-maven-plugin
Description: The Oracle WebLogic Server 12.2.1 Maven plugin
Group Id: com.oracle.weblogic
Artifact Id: weblogic-maven-plugin
Version: 12.2.1-2-0
Goal Prefix: weblogic

This plugin has 23 goals:

  Description: This goal is a wrapper for the weblogic.appc compiler.

  Description: Create a domain for WebLogic Server using the default domain
    template. For more complex domain creation use the WLST goal. Note:
    Starting in WLS 12.2.1, there is a single unified version of WLST that
    automatically includes the WLST environment from all products in the


  Description: Reads a JAX-WS service endpoint implementation class and
    generates all of the portable artifacts for a JAX-WS web service.

  Description: Parses wsdl and binding files and generates Java code needed
    to access it.

For more information, run 'mvn help:describe [...] -Ddetail'

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.455 s
[INFO] Finished at: 2017-09-11T19:51:53-07:00
[INFO] Final Memory: 12M/123M
[INFO] ------------------------------------------------------------------------

This has the list of all the goals and a basic description on how to use them. For a more in-depth description use the -Ddetail flag.

Note: More info on how to use the plugin can also be found at Using the WebLogic Maven Plug-In.

At this point all the necessary plugin files are now copied into the /u01/oracle/.m2/repository directory and by copying it's content to any other .m2/repository directory on any other system it should have the ability to now create Maven archetypes for Oracle Weblogic as well as connect with WebLogic and control it.

3. Installing Maven

Now we go back to the j-m_zone to install Maven. As the first step we need to install the Java packages, and because we'll need it later we'll also install Git:

oracle@wls_zone:~$ exit

[Connection to zone 'wls_zone' pts/4 closed]
root@solaris:~# zlogin j-m_zone
[Connected to zone 'j-m_zone' pts/4]
Last login: Sun Oct  1 11:40:35 2017 on pts/2
Oracle Corporation      SunOS 5.11      11.3    July 2017
root@j-m_zone:~# pkg install jdk-8 git

Now we can pull down the Maven binaries from their website with wget. Note that I'm using version 3.2.5 in this case to stay the same as the version that shipped with WebLogic:

root@j-m_zone:~# wget https://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz

Note: You might need to set the https_proxy environment variable to allow wget to connect outside your network.

Then unpack the files into /opt:

root@j-m_zone:~# cd /opt
root@j-m_zone:/opt# tar xvfz /root/apache-maven-3.2.5-bin.tar.gz

And test if it runs correctly:

root@j-m_zone:/opt# /opt/apache-maven-3.2.5/bin/mvn -v
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T09:29:23-08:00)
Maven home: /opt/apache-maven-3.2.5
Java version: 1.8.0_141, vendor: Oracle Corporation
Java home: /usr/jdk/instances/jdk1.8.0/jre
Default locale: en, platform encoding: ISO646-US
OS name: "sunos", version: "5.11", arch: "amd64", family: "unix"

3.1 Create User Jenkins

The next step is to create a new user that will run the Jenkins processes. We're doing this as it's actually going to be Jenkins that will be using Maven to build the Java code and push it to WebLogic and even though we're not going to install Jenkins in this blog we need to put the plugins in place so we can use them later. So first create user jenkins:

root@j-m_zone:/opt# useradd -m jenkins
80 blocks
root@j-m_zone:/opt# su - jenkins
Oracle Corporation      SunOS 5.11      11.3    July 2017

Now edit .profile to include the Maven binaries in the PATH by changing this line:

export PATH=/usr/bin:/usr/sbin:/opt/apache-maven-3.2.5/bin

And test again if Maven runs:

jenkins@j-m_zone:~$ source .profile
jenkins@j-m_zone:~$ mvn -v
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T09:29:23-08:00)
Maven home: /opt/apache-maven-3.2.5
Java version: 1.8.0_141, vendor: Oracle Corporation
Java home: /usr/jdk/instances/jdk1.8.0/jre
Default locale: en, platform encoding: ISO646-US
OS name: "sunos", version: "5.11", arch: "amd64", family: "unix"

4. Copy in the Oracle Maven WebLogic Plugins

Now we get to copy the plugins we've built in the wls_zone across to this one and put them into place so we can use them. To do this we need to copy the ~/.m2/repository directory across from user oracle on one side into that same directory under user jenkins on the other. Note that if you needed a proxy set earlier you probably need to copy the ~/.m2/settings.xml over too. So to get both we only need to pull ~/.m2 across with rsync:

jenkins@j-m_zone:~$ rsync -avu --progress oracle@ .
The authenticity of host ' (' can't be established.
RSA key fingerprint is b7:50:99:9f:dc:71:19:f0:d3:a4:93:b0:a5:e5:f4:71.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
receiving incremental file list
          2,132 100%    2.03MB/s    0:00:00 (xfr#1, ir-chk=1004/1006)
            686 100%  669.92kB/s    0:00:00 (xfr#2, ir-chk=1003/1006)


          1,610 100%    1.58kB/s    0:00:00 (xfr#5104, to-chk=1/7729)
             62 100%    0.06kB/s    0:00:00 (xfr#5105, to-chk=0/7729)

sent 114,493 bytes  received 454,986,747 bytes  17,173,631.70 bytes/sec
total size is 454,356,946  speedup is 1.00

Note: The rsync also pulled in the .m2/archetype-catalog.xml file. More about that next.

5. Building a New Maven Archetype

The plugin we've copied across not only holds the bits needed to connect to WebLogic, but it also includes sample archetypes for WebLogic that you can build and use as the basis of your new app or just to test if everything is working. The .m2/archetype-catalog.xml holds the list of archetypes we can use.

We're going to use the basic-webapp archetype and create an app called my-webapp using Maven:

jenkins@j-m_zone:~$ mvn archetype:generate -DarchetypeGroupId=com.oracle.weblogic.archetype -DarchetypeArtifactId=basic-webapp -DarchetypeVersion=12.2.1-2-0 -DgroupId=com.solarisdemo -DartifactId=mywebapp -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...


Confirm properties configuration:
groupId: com.solarisdemo
artifactId: mywebapp
version: 1.0-SNAPSHOT
package: com.solarisdemo
 Y: :

Press [enter]

[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: basic-webapp:12.2.1-2-0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.solarisdemo


[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:16 min
[INFO] Finished at: 2017-09-15T08:14:31-07:00
[INFO] Final Memory: 18M/123M
[INFO] ------------------------------------------------------------------------
jenkins@j-m_zone:~$ ls
local.cshrc    local.login    local.profile  mywebapp
jenkins@j-m_zone:~$ ls mywebapp/
pom.xml  src

Look around the mywebapp directory and the contents of the pom.xml file and find the Java source files. Then edit the pom.xml file and change these lines:


To now read:


Note: That you'll need to point to the IP address of the wls_zone as it has WebLogic that we want to connect to.

Note 2: The addition of remote and upload, these are needed if you want to use Maven to connect to anything else than localhost. Please look an explanation on the Oracle Documentation for the Maven plugin.

Note 3: That the password is not encrypted, for details on how to encrypt your password please got to the Maven page on encrypting server passwords.

6. Build and Deploy the Java App

At this point we're ready to build the Java app and then deploy it to WebLogic. We do this by running Maven with the pre-integration-test goal:

jenkins@j-m_zone:~$ cd mywebapp/
jenkins@j-m_zone:~/mywebapp$ mvn pre-integration-test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building basicWebapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------


[INFO] Command flags are: -noexit -deploy -username weblogic -password ******* -name basicWebapp -source /export/home/jenkins/mywebapp/target/basicWebapp.war -upload -verbose -remote -adminurl t3://
weblogic.Deployer invoked with options:  -noexit -deploy -username weblogic -name basicWebapp -source /export/home/jenkins/mywebapp/target/basicWebapp.war -upload -verbose -remote -adminurl t3://
<Sep 15, 2017 8:52:21 AM PDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, basicWebapp [archive: /export/home/jenkins/mywebapp/target/basicWebapp.war], to configured targets.> 
Task 0 initiated: [Deployer:149026]deploy application basicWebapp on AdminServer.
Task 0 completed: [Deployer:149026]deploy application basicWebapp on AdminServer.
Target state: deploy completed on Server AdminServer

Target Assignments:
+ basicWebapp  AdminServer
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:22 min
[INFO] Finished at: 2017-09-15T08:52:27-07:00
[INFO] Final Memory: 33M/123M
[INFO] ------------------------------------------------------------------------

Now to test if the web app is up and running go to http://<wls_zone>:7001/basicWebapp in Firefox and you should see something like this:

At this point Maven has been set up to be able to connect to the WebLogic instance and control it. In this case we've done a simple build and deploy by using the pre-integration-test goal but there are many other goals you can use, even to create new WebLogic domains and starting and stopping them. For more information check out the Oracle documentation on the different types of goals.

This ends this blog on installing Maven on Oracle Solaris. Check in later for the next part in this Hands on Lab series.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.